Replies: 1 comment 1 reply
-
Unfortunately there's also changes possible from for example setUiState, results, so any optimisations would need to have to take that in account as well. You can also have multiple of the same widget, which would also impact all other widgets. Are you seeing actual performance impact from these comparisons in the life cycle that you'd like to see optimised or is this more hypothetical? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While developing my own custom Angular components using the exposed
connectors
, I found that a lot of times when a widget triggers a change, its component should not react to its changes, or react differently when the source of change is the widget used in the component. Point is there can be made optimizations when we know the source of the change.Examples
Router
to use@angular/router
I noticed withincreateRouterMiddleware.ts
whenrouter.onUpdate
triggers, this will also triggeronStateChange
, which in turn triggersrouter.write
iflastRouteState
differs fromrouteState
. But in this instance it should never even get to comparing these two, because it's nonsensical in this case to react to it's own changes. (on a side note I believe comparing these route states should be the responsibility of theRouter
, if it will do it at all, it's up to the implementation) So in turn there needs to be special logic and caching inRouter
in order to determine when to trigger a route write and when to trigger a IS.JS state change. Ifrouter.write
would receive the source of the change, we could determine that the change was triggered from within theRouter
and simply ignore it.SearchBoxWidget
has no way of telling the change came from itself, so there's always a needless comparison between the content of the input element and statequery
, in fact it can only be changed by theRouter
if I'm not mistakenSortByWidget
currentRefinement
can only be changed by theRouter
orrefine
in the widget, potential optimizations pop upI'm not sure if this is true, but all state changes trigger all callbacks, there's no selectivity, this ideally should be handled internally, but a more simple solution for now can be my proposal. Which is the ability to pass a variable of any type to the
refine
s, and to receive this optional variable on state changes everywhere else as the identifier of the source of the change.So for instance if on the
SearchBoxWidget
werefine
with aSymbol
object as the identifier, on the callback we can check against thisSymbol
to determine that the change is from within or from a specific widget.EDIT: I can see that there is a property on the widgets:
$$widgetType
. If this would get exposed somehow as the source of the change it would pretty much be exactly what I am looking for, albeit maybe a little less flexible and more limited.Beta Was this translation helpful? Give feedback.
All reactions