Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 20 12:55
    dependabot[bot] closed #72
  • Jul 20 12:55
    dependabot[bot] commented #72
  • Jul 20 12:55
    dependabot[bot] labeled #74
  • Jul 20 12:55
    dependabot[bot] opened #74
  • Jul 12 23:56
    dependabot[bot] labeled #73
  • Jul 12 23:56
    dependabot[bot] labeled #72
  • Jul 12 23:56
    dependabot[bot] opened #73
  • Jul 12 23:56
    dependabot[bot] opened #72
  • Jul 11 00:34
    dependabot[bot] labeled #71
  • Jul 11 00:34
    dependabot[bot] opened #71
  • Jun 21 06:53
    dependabot[bot] labeled #70
  • Jun 21 06:53
    dependabot[bot] opened #70
  • Jun 21 06:53
    dependabot[bot] labeled #69
  • Jun 21 06:53
    dependabot[bot] opened #69
  • Jun 14 03:49
    dependabot[bot] labeled #68
  • Jun 14 03:49
    dependabot[bot] opened #68
  • Jun 08 00:16
    dependabot[bot] labeled #67
  • Jun 08 00:16
    dependabot[bot] opened #67
  • Jun 06 09:18
    dependabot[bot] labeled #66
  • Jun 06 09:18
    dependabot[bot] opened #66
Sunny Gonnabathula
@sunny-g
Hi! Have you tested this with react native?
Jichao Ouyang
@jcouyang
@sunny-g no, but if you get a chance, please let me know
songdun
@songdun
当出现flatMapError时,就不能再运行了吗?
产生情况如下:
search-type这个例子
正常情况下是可以一直重复发送请求并显示查询结果,但当认为断网使其报错再连上网时,它只会发送请求,而请求结果不能显示在下方,我用chrome的react插件看该组件的state也没有改变
Jichao Ouyang
@jcouyang
是的,一个connect component的所有sinks最终会被merge成一个stream,所以stream上出现任何错误,这个component就废了
songdun
@songdun
还有个问题,我想在rest请求数据的成功的时候alert(成功),但是不知道该加在什么地方最合适?
也就是说如果这个component就废了,就只能刷新浏览器才能恢复了?没有其他的更好的方法?
Jichao Ouyang
@jcouyang
副作用可以tap到你发rest的后面
如果要恢复可以用 recoverWith 返回一个default的stream
但是已经有异常了,重新render或者刷新页面也应该算是正常的行为
songdun
@songdun
这个貌似是应该刷新,现在线上的产品,也是一旦发生任何错误,就不能继续下去,感觉很脆弱的样子
songdun
@songdun
副作用可以tap到你发rest的后面 意思是说放到.then()里?
Jichao Ouyang
@jcouyang
我说的异常是指没有捕获的异常会让stream挂掉,产品上应该要捕获所有可预测的异常
songdun
@songdun
那这个捕获异常是像以前那样用try catch 还是也有函数式的写法?
Jichao Ouyang
@jcouyang
stream的每个变换只是个纯函数,函数里try catch,或者如果函数返回promise,那就是promise的catch
songdun
@songdun
那个搜索的例子是发生事件之后才发送请求获取数据,如果我想要一开始就发送请求获取数据然后渲染组件该怎么调整呢?
Jichao Ouyang
@jcouyang
一开始获取数据就跟todomvc那个差不多
Nicola Squartini
@tensor5
Hi! Why does the dataFlow parameter of connect return a state transform stream rather than a state stream? Can't you return a state stream and use the scan method of most.js?
Jichao Ouyang
@jcouyang
@tensor5 good question. because state transform stream is more descriptive, it describe the transform, not just a result. Also the time of calling the transform function is under react control, not most, so it's hard to guarantee the order of the state in stream will be the result that react render. But transdorm function is pure, it doesn't matter when it's been called, it only depends on the parameter which is the state when its called. That's why I made transform function first class, not state value
Nicola Squartini
@tensor5
Thanks for the answer. I asked this question because I'm comparing react-most with cycle.js; although the two frameworks look similar, in cycle you generally have a stream of states that is mapped into a stream of virtual doms, while in react-most (if I understand correctly) you have a stream of state transforms that are composed together to produce the final state of the react component.
John Rees
@johnrees

thank you for the great library! I'm still learning reactive programming but am starting to understand its potential power.

what would be the 'correct way' to handle when the user clears the searchbox (to remove all results) in this live-search example?

https://github.com/reactive-react/react-most/blob/master/examples/type-n-search/src/app.jsx#L25

Jichao Ouyang
@jcouyang

@johnrees the updateSink$ is only declare how we should update the result when you modify the query, so if you need to handle clear, the best way to do it separated but similar as updateSink$

let search$ = intent$.filter(i=>i.type=='search')
                           .debounce(500)
                           .map(intent=>intent.value)
 let clearSink$ = search$ .filter(query=>query.length > 0).map(_=>state=>({results: []}))

and return the sinks as well

  return {
    search: value=>({type:'search',value}),
    clearSink$,
    updateSink$,
}
John Rees
@johnrees

fantastic @jcouyang, that makes sense and works great thanks https://github.com/johnrees/react-most/blob/9be68c1b72a9ea8a4112b9ce82ed6c147ef414a7/examples/type-n-search/src/app.jsx#L26-L27

I can make a PR if you want it in the /examples? There is a bug when the textbox is cleared that previous promises get resolved and add a result.

https://www.youtube.com/watch?v=UM3ijK4aswY&feature=youtu.be

I think this might be related to .switch()? I will try and figure it out :D

Jichao Ouyang
@jcouyang
@johnrees i guess it's relate to the debounce
what happen if you move debounce to search$
let search$ = intent$.filter(i=>i.type=='search')
.map(intent=>intent.value.trim()).debounce(500)
John Rees
@johnrees
yes I could do that but then it will take 500ms to empty the list if the textbox is clear, and ideally that would be an instant effect. The earlier promises need to be cancelled somehow I think?
Jichao Ouyang
@jcouyang
Hmm:thought_balloon: That maybe depending on how you design it. IMO the behavior that keep typing and deleting consistent which is OK, unless you have a clear button then if we click the button it should immediately clear your input and result.