You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug useHostStyles internally uses useHostStyleVariables() and useHostFonts()
Inside useHostStyleVariables and useHostFonts are assigning different callback to app.onhostcontextchanged which causes overriding while using both of methods together inside useHostStyles:
Overriding happens due to onhostcontextchanged implementation which is based on setNotificationHandler.
typescript-sdk mentions that previous handlers will be overwritten:
/** * Registers a handler to invoke when this protocol object receives a notification with the given method. * * Note that this will replace any previous notification handler for the same method. */setNotificationHandler<MextendsNotificationMethod>(method: M,handler: (notification: NotificationTypeMap[M])=>void|Promise<void>)
To Reproduce
Steps to reproduce the behavior:
Try to track host style variables changes after using useHostStyles, it wont we tracked
Expected behavior useHostStyles() works w/o overriding onhostcontextchanged callbacks
Proposal
Instead of reusing useHostStyleVariables and useHostFonts inside useHostStyles just put all needed code into single callback and assign it to onhostcontextchanged.
Describe the bug
useHostStylesinternally usesuseHostStyleVariables()anduseHostFonts()Inside
useHostStyleVariablesanduseHostFontsare assigning different callback toapp.onhostcontextchangedwhich causes overriding while using both of methods together insideuseHostStyles:Overriding happens due to
onhostcontextchangedimplementation which is based onsetNotificationHandler.typescript-sdk mentions that previous handlers will be overwritten:
To Reproduce
Steps to reproduce the behavior:
Try to track host style variables changes after using useHostStyles, it wont we tracked
Expected behavior
useHostStyles()works w/o overridingonhostcontextchangedcallbacksProposal
useHostStyleVariablesanduseHostFontsinsideuseHostStylesjust put all needed code into single callback and assign it toonhostcontextchanged.OR
Implement
subscribe(eventName)/unsubscribe(eventName)methods for multiple handlers. ThenuseHostStyleVariablesanduseHostFontswould look like: