-
-
Notifications
You must be signed in to change notification settings - Fork 397
Remove getDynamicStyles from core #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
85719bc
5791dbb
abe363d
2af4fc0
e0cd153
4a81a4c
7250b3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,34 @@ import { | |
| } from 'jss' | ||
| import type {Observable} from './types' | ||
|
|
||
| const isObservable = value => value && value[$$observable] && value === value[$$observable]() | ||
| const isObservable = (value: any) => value && value[$$observable] && value === value[$$observable]() | ||
|
|
||
| export type Options = UpdateOptions | ||
|
|
||
| function getObservableStyles(styles: Object): Object | null { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are not using this anywhere, why having it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need it for proper integration into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What integration are you talking about? mb we should do it differently in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proper There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I'm also not sure If we actually need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we end up having a function that knows about both, functions and observables, it shouldn't be in one of those plugins, but somewhere else. Duplicating that function in both is also not very nice, it might need some adjustments in the future and having it twice doesn't make it easier to maintain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But why do we need to have a function which knows about both? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that these function should live in their respective plugin packages and not in the core. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that core is not the ideal place for them, but I want to keep performance-first constraint. If we need to loop over styles twice just for the sake of functions living in separate packages, it is not quite performance-first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only place we are using |
||
| let to = null | ||
|
|
||
| for (const key in styles) { | ||
| const value = styles[key] | ||
| const type = typeof value | ||
|
|
||
| if (isObservable(value)) { | ||
| if (!to) to = {} | ||
| to[key] = value | ||
| } else if (type === 'object' && value !== null && !Array.isArray(value)) { | ||
| const extracted = getObservableStyles(value) | ||
| if (extracted) { | ||
| if (!to) to = {} | ||
| to[key] = extracted | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return to | ||
| } | ||
|
|
||
| export {isObservable, getObservableStyles} | ||
|
|
||
| export default function observablePlugin(updateOptions?: Options) { | ||
| return { | ||
| onCreateRule(name?: string, decl: JssStyle, options: RuleOptions): Rule | null { | ||
|
|
||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.