Skip to content

Add useAction to solve takeLatest problem #2

@acrazing

Description

@acrazing
const businessesBox = createAmosDictBox('businesses')

const getBusinessInfo = action((dispatch, select, businessId: number) => {
  const business = await fetch('path/to/business')
  dispatch(businessesBox.setItem(businessId, business))
})

const Demo: FC = () => {
  const r = useAction(getBusinessInfo(businessId), businessId /* cache key */, true /* suspense */)
  const [business] = useSelector(businessesBox.getItem(businessId))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions