funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
martinklepsch 2017-01-06T05:47:37.000431Z

@niwinz is there some utility or so in beicon that helps me turn a callback based API into a stream?

martinklepsch 2017-01-06T05:52:51.000432Z

Could probably whip up something myself just wondered if there’s some utility for that 🙂

martinklepsch 2017-01-06T10:33:42.000437Z

I guess a debouncer mixin might be better since I can reuse that easier in other components

martinklepsch 2017-01-06T10:53:49.000438Z

Hm. Something with my get-completions! function is still wrong, Can’t get the StartPlacesAutocompletion. Seems when I merge one ended stream with another one it ends it too? Or something like that? 😄

martinklepsch 2017-01-06T10:56:59.000439Z

Ah! — rx/subject!

martinklepsch 2017-01-06T11:03:59.000441Z

Hm, still doesn’t quite work...

niwinz 2017-01-06T14:24:04.000442Z

@martinklepsch (rx/map (fn [x] (get-completions! serv x)))

niwinz 2017-01-06T14:24:07.000443Z

is wrong

niwinz 2017-01-06T14:24:25.000444Z

it should be mapcat

martinklepsch 2017-01-06T14:24:33.000445Z

I tried mapcat

niwinz 2017-01-06T14:24:39.000446Z

then I think that get completions is also wrong

martinklepsch 2017-01-06T14:24:56.000447Z

yeah, I think the culprit is somewhere in that get-completions fn

niwinz 2017-01-06T14:24:59.000448Z

it returns a stream that never finishes

niwinz 2017-01-06T14:25:16.000449Z

that is the objective of get completions?

martinklepsch 2017-01-06T14:25:27.000450Z

Also tried rx/end instead of rx/push!

martinklepsch 2017-01-06T14:25:37.000451Z

The objective is to return a stream with one item

niwinz 2017-01-06T14:26:35.000453Z

ok

niwinz 2017-01-06T14:26:41.000454Z

so rx/push!

niwinz 2017-01-06T14:26:45.000455Z

and then rx/end!

niwinz 2017-01-06T14:26:53.000456Z

(rx/end! subject)

martinklepsch 2017-01-06T14:27:51.000457Z

uh, weird. I tried (end! subject thing) and thought it would put thing on the stream and end it.

niwinz 2017-01-06T14:27:52.000458Z

On the end you have two ways convert callback code to rx streams returning code

niwinz 2017-01-06T14:28:05.000459Z

using rx/create or using rx/subject in the way as you have used it

martinklepsch 2017-01-06T14:28:07.000460Z

There was no exception for the (end! subject thing)

niwinz 2017-01-06T14:28:12.000461Z

with the finally calling rx/end! on subject

niwinz 2017-01-06T14:28:55.000462Z

the thing is just ignored because end! only has arity 1

martinklepsch 2017-01-06T14:29:18.000463Z

right but shouldn’t it cause an error then, calling a function with wrong arity?

niwinz 2017-01-06T14:29:28.000464Z

no, in javascript no...

martinklepsch 2017-01-06T14:29:33.000465Z

maybe I’m remembering wrongly what I did, will re-check later

martinklepsch 2017-01-06T14:29:44.000466Z

oh, ok, that’s rough 😄

martinklepsch 2017-01-06T14:29:59.000467Z

never consciously ran into that

martinklepsch 2017-01-06T14:43:20.000468Z

@niwinz generally would that be the approach you would take or would you use component lifecycle, decouple debounce & actual action, .... ?

niwinz 2017-01-06T14:43:58.000469Z

It depends, but if you want to debounce, probably I will use the component stuff

martinklepsch 2017-01-06T14:43:59.000470Z

I guess question is if you think this is a good area for RX over other solutions

niwinz 2017-01-06T14:44:12.000471Z

debounce for UI stuff

niwinz 2017-01-06T14:45:06.000472Z

on the other hand, this not looks bad

martinklepsch 2017-01-06T14:46:26.000473Z

I’m also tending towards using component lifecycle now mostly because I can make the debounce stuff separate to the action I’m doing after debounce

martinklepsch 2017-01-06T14:46:41.000474Z

(which is coupled here and not really nice I’d say)

niwinz 2017-01-06T14:47:57.000475Z

+1

niwinz 2017-01-06T14:48:07.000477Z

I agree with that