-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Sugar for running simple workers and actions #75
Comments
My concern here is that it's going to be an even bigger temptation to read from the Given that, still want this? |
I think my concern is more around obscuring how various calls to the proposed |
Also, to clarify the discussion going forward, this proposes two separate and unrelated things:
|
@rjrjr Yup! The handler should be receiving both the result of the worker as well as the state. I am mostly looking for a way to make the common case of get data from a service and make a new state based on the result a bit shorter to write. |
Hi folks, I wrote an extension function
run
which tries to reduce some of the boilerplate associated with running workers. I find myself writing a bit more boilerplate that the minimum when creating a worker that changes state. I'd like the ability to pass a lambda torunningWorker
that is anAction.Updater
while still receiving the result of my worker.As an example:
Ideally I wanted to collapse the following to something that asks for a suspended function to execute and a state to show with the response
I got pretty close but cannot get a working solution that allows me to pass an
updater
to myrun
function without having to also pass an action:From what I gather (apologies this is all new to me) the issue is with
action
being unable to pass a param toupdater
the only reason the above example compiles is thatit
is being captured from the "handler" without ever getting passed between the action and the action.updater.For context here is my current solution
I'm coming from mvrx which has a similar api as I describe above where a single
execute
function both acts as a mutator and an action. It would be helpful to have the same here.The text was updated successfully, but these errors were encountered: