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

bug(ApiActionThunk): seems like our types or type composition is off #98

Open
ramfox opened this issue Feb 12, 2021 · 0 comments · May be fixed by #666
Open

bug(ApiActionThunk): seems like our types or type composition is off #98

ramfox opened this issue Feb 12, 2021 · 0 comments · May be fixed by #666
Labels
bug Something isn't working
Milestone

Comments

@ramfox
Copy link
Member

ramfox commented Feb 12, 2021

// TODO (ramfox): because of the way that ApiActionThunk is composed, this is
// the only way to get to the underlying Promise
// it's pretty odd syntax, and it makes me think that perhaps our types
// aren't composed in the most optimal way
// the dream would be to use this pattern: dispatch(someAction()).then(() => dispatch(someOtherAction())).catch((failure) => doSomethingWith(failure))

Because of the way that ApiActionThunks are composed, the only way to get to the underlying promise is to use this syntax:

import {useDispatch} from 'react'
import {someAction} from '/someAction'

const Component: () => {
  const dispatch = useDispatch()
  someAction()(dispatch)
    .then(() => { // thing you want to do when the promise has returned })

This seems off & maybe we aren't surfacing or composing our types in an optimal way.

@chriswhong chriswhong added the bug Something isn't working label Jun 25, 2021
@b5 b5 added this to the v0.1.0 milestone Sep 10, 2021
@boandriy boandriy linked a pull request Jan 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants