Listeners performance #3274
-
I been using listener api lately but I been limiting myself as I believe there might be a cost in memory if we have many observables. So my question will be if having many listeners listening in my app there will be any sort of degradation in my app performance? Also does listener api works as a callback function or it's an observable itself? because if it's not an observable I believe there will be no cost. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The listener middleware runs one check per listener per action dispatched. Typically, that should be a pretty simple comparison, like If you have many listeners and dispatch many actions frequently, then the cost can add up over time, but mostly in the sense that "running more code takes longer than running less code". Realistically, though, it's not going to be an issue. |
Beta Was this translation helpful? Give feedback.
The listener middleware runs one check per listener per action dispatched. Typically, that should be a pretty simple comparison, like
action.type === 'some/action/string'
. That's cheap.If you have many listeners and dispatch many actions frequently, then the cost can add up over time, but mostly in the sense that "running more code takes longer than running less code".
Realistically, though, it's not going to be an issue.