Skip to content

Need standaloneflow example #479

Answered by xaviergonz
aboyer1013 asked this question in Q&A
Discussion options

You must be logged in to vote

The typings were wrong, I just published v0.69.8 with a fix.

Hopefully the following test can give you an insight on how to do it:

test("standaloneFlow", async () => {
  @model("standaloneFlow/Data")
  class DataModel extends Model({ x: prop(0) }) {
    @modelFlow
    fetchX = _async(function* (this: DataModel, y: number) {
      const data = this.x + y
      const flowResult = yield* _await(fetchData(this, y))
      assert(flowResult, _ as number)
      expect(flowResult).toBe(data)
      return flowResult
    })
  }

  const fetchData = standaloneFlow("actions/fetchData", function* (target: DataModel, y: number) {
    const data = target.x + y

    const promiseResult = yield* _await(Pr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aboyer1013
Comment options

Answer selected by aboyer1013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants