-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
EStyleSheet.subscribe callback get called only one time #109
Comments
hi @dhl1402 ! |
Sorry for late reply. Totally forgot about this.
If styles is already built, the listener will be called but will not be saved for the next |
hi @vitalets, here the reproduce snack. please take a look 😀 |
I've got you point. Yes, this is a bug from the time when there was no re-build. Thanks! subscribe(event, listener) {
if (event !== BUILD_EVENT) {
throw new Error(`Only '${BUILD_EVENT}' event is currently supported.`);
}
if (typeof listener !== 'function') {
throw new Error('Listener should be a function.');
}
this.listeners[BUILD_EVENT] = this.listeners[BUILD_EVENT] || [];
this.listeners[BUILD_EVENT].push(listener);
if (this.builded) {
listener();
}
} |
Great! I think we need a way to remove the listeners. Maybe return an unsubscribe function or return the index of listener and expose an unsubscribe function |
I think we can introduce unsubscribe(event, listener) { } By the way could you describe your workflow with subscription? |
I don't use subscription for defining components but for re-calculating styles after theme change as mentioned in #47 |
When style is already built, EStyleSheet.subscribe's callback will get called only one time immediately. Is this designated behavior??
The text was updated successfully, but these errors were encountered: