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
unfortunately I didn't found any deeper documentation about priority. The documentation says that there is a priority property and you can set a integer value but there is no example or use case.
However, I would like to begin with one use case. I have one function that should be called as the last event listener since it depends on settings the previous listeners will set. Therefore it would be good to know what the default priority is? If it would be 1 I hopefully could set priority to 0 and the function would be called at the end.
However, could somebody @ajacksified tell me how to manage such situations with Mediator.js?
The text was updated successfully, but these errors were encountered:
Correct; right now, it only changes current priority, there's no way to tell a function to always be called last; the only way to do it would be to add new listeners with a priority of 1 to that they're added later.
Do you have ideas on how you might want to work with the api to tell something to always be last?
@ajacksified This is how I solved the problem the other day: In the related app I created a requireJS module called "mediator". Every other module will require that module. It will add observers/listeners to that module so not directly to the mediatorJS plugin. So I can set a default priority of e.g. 10 if no priority was defined. So now I have to options: Define a priority or define no priority. If one is defined, then go ahaid. If no one is defined, it will define e.g. 10 so that there is enough space for e.g. 9 listeners with less priority (last-listeners).
To your question. IMHO it would be a mistake to add a option like "last" so that defined listeners will be called at the end. The question would be: how do you act if there are multiple listeners with that property? So my solution for your plugin would be to define a default (fallback) priority like 0 and allow minus e.g. -10 priority to set "last"-listeners.
Hi,
unfortunately I didn't found any deeper documentation about priority. The documentation says that there is a priority property and you can set a integer value but there is no example or use case.
However, I would like to begin with one use case. I have one function that should be called as the last event listener since it depends on settings the previous listeners will set. Therefore it would be good to know what the default priority is? If it would be
1
I hopefully could set priority to0
and the function would be called at the end.However, could somebody @ajacksified tell me how to manage such situations with Mediator.js?
The text was updated successfully, but these errors were encountered: