Skip to content
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

Example results in "Missing continuation parameter in resume" error #4

Open
wrnrlr opened this issue Jan 7, 2024 · 1 comment
Open

Comments

@wrnrlr
Copy link

wrnrlr commented Jan 7, 2024

Hi, I don't know how how active this project is still but I've been learning about effects and I think it is a beguiling idea.
Most other libraries are too hard to understand , so I definably appreciate your work.
I think there is a small error in the examples where you forget the pass the continuation k as a argument to resume.
It should be something like this (from my limited understanding).

   const withDataSource = handler({
      getUser: (id,k) => eff(function* () {
         const user = yield waitFor(() => fetchApi("users/" + id))
         return yield resume(k,user)
      }),
      sendNotification: (options,k) => eff(function* () {
         const { subscriber, user } = options;
         const result = yield waitFor(() => fetchApi("users/" + subscriber.id + "/send", "POST", options))
         return yield resume(k,result)
      })
   })
@wrnrlr wrnrlr closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2024
@nythrox nythrox reopened this Feb 5, 2024
@nythrox
Copy link
Owner

nythrox commented Feb 5, 2024

Hey @wrnrlr , sorry for the late answer.
You're absolutely right! Thanks for the catch.
resume always takes the continuation as the first argument and the resume value as the second, while handlers receive their parameters first and the continuation as the last argument. I did this because not all handlers care about the continuation (so most can ignore the last argument), but when resuming the continuation is the one thing you can't forget.
I'm not sure if all of the docs are respecting this, since I remember writting part of the docs before finishing the final API.
I'll review them as soon as I have some time, but you can open a PR with the changes in the /docs folder and I'd be glad to accept it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants