Calling into the reducer from a background thread directly #1537
Replies: 2 comments
-
Hi @quantamrhino, is it necessary to send actions into the system at a high frequency? In particular, does the reducer do real logic with each little audio update, or is it just accumulated into some final value? In general, you should avoid sending actions at a high frequency in TCA. We have a dedicated section to this topic in our performance article. Instead of sending many actions from an effect you can often perform all the work needed in the effect, and send a single summary action at the end, or a few progress actions along the way. Any work you perform inside I'm not sure if any of the above helps, but if it doesn't then I think it would help to get more details about your exact situation and a bit more code. And there is one thing in your message that may be a misunderstanding, so here is some clarification:
This is not true. You can send actions using a plain |
Beta Was this translation helpful? Give feedback.
-
Thanks for your prompt response. |
Beta Was this translation helpful? Give feedback.
-
I have an mic tap which returns audio data at a high rate, from a background (Audio thread) context.
In this audio thread context, apple says it's not allowed to sleep or block or allocate memory etc. How do I offload that work to a reducer?
I would like to invoke an action in a reducer, and then continue running analysis code in the background, on a different thread. (ideally without the main thread hop, then a .run to take it off the main thread again).
If I declare a global store, I can't send actions on it without the withViewStore.
So how are non-views to send an action to a store?
I'm completely at my wit's end trying to figure this out.
I do hope I don't have to scrap TCA because I do really love it and the test coverage and reasoning ability it provides.
Thank for any help/insights you can provide!
My reducer is simple, like this:
Beta Was this translation helpful? Give feedback.
All reactions