Gijs van Dam
I like it! I can think of a few use cases. There will be a day in the near future where I am going to use it, for sure.
Not a JS expert, but I don't think it's a pattern. onReceive is just a delegate for your own function. Like map or filter
When are we allowed to call something a pattern? :D I'm not sure if you could call it a delegate. It's a function, not a function signature that is passed along with onReceive. But delegation is a confusing term: saturnflyer.com/blog/the-gang-… (gijsvandam.nl/reply/2022/02/…)
You can think of this as a "partial actor model" pattern, if you squint 🧐 Here, you can: 📥 Receive messages 📤 Send messages to parent 🗒️ Keep local state in the closure But you can't spawn or talk to other actors.
It has a signature, the "e" is an argument. Call it lambda, or eventhandler, or pointer to function then, eheheh
I like it! I can think of a few use cases. There will be a day in the near future where I am going to use it, for sure.
I thought it had a name already, Invoke Callback. It is my xstate-best-friend btw, I find it the most versatile of services invocation patterns ✨