Skip to content

感谢 repo, 三个问题 #6

@HaveF

Description

@HaveF
  1. 关于 reaction$
    reaction$ 感觉和 tostream , 再配合个 from 功能差不多
    是不是可以直接用这个官方的维护性更好?

  2. 关于 action 的一些疑问

import { types, effect, action } from 'mst-effect'
import { map, switchMap } from 'rxjs/operators'

const Model = types
  .model({
    value: types.string,
  })
  .actions((self) => ({
    fetch: effect<string>(self, (payload$) => {
      function setValue(value: string) {
        self.value = value
      }

      return payload$.pipe(
        switchMap((url) => fetch$(url)),
        map((value) => action(setValue, value)),
      )
    }),
  }))

其中

      function setValue(value: string) {
        self.value = value
      }

这一部分可以写在和 fetch 同级的地方吗? 这样好像方便 compose 一些?

  1. 老实讲, 整个库还是让我有点困惑

https://egghead.io/lessons/react-defining-asynchronous-processes-using-flow
2分51秒的地方
截屏2021-05-21 上午8 56 22
在 getSuggestion 的地方直接使用 rxjs, 在 subscribe 调用下 mst 的 actions 不就可以了? 为何如此大动周折?

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