Fable: Any samples on using fable with react and rxjs

Created on 20 May 2016  路  6Comments  路  Source: fable-compiler/Fable

Hi,
Are there any known samples of fable with react and rxjs?

regards,
Richard.

discussion

Most helpful comment

@alfonsogarciacaro You saved the day! Both suggestions worked like a charm. Thank you!
For reference this is the working solution: https://gist.github.com/MecuSorin/67c469e6e55e7f59d03117dce28c1086

All 6 comments

Not yet, I guess we should create an adapter to use RxJS in a more idiomatic way like FunScript did.

Remember you can also use directly FSharp.Core observables out of the box (though there're not as many functions available as with RxJS). Unfortunately, at the moment the IObservable interface is not exactly the same as the one used by RxJS so they're not directly exchangeable :/

I just want to observe changes to some system data and update my view according so I need nothing complicated. Will check it out.

Checked out the observable test page and got everything I needed. IObservable was enough for what I wanted.

Needing some RxJs functionality I attempted to make a small footprint adaptation. But failed on a core item for me zip.
As a base project I used the safe template and just installed the rxjs with yarn add rxjs.
The gist is https://gist.github.com/MecuSorin/65693b0ec426ee41fd276fc99098df68

image
My problem is that zip is not outputting anything:
image

Any idea what I am doing wrong? I was using https://www.learnrxjs.io/learn-rxjs/operators/combination/zip as reference for the javascript side

Hmm, not sure but can you try removing the parens in the zip? This may make F#/Fable think you want to pass an actual tuple (an array in JS) instead of two arguments:

type IRX =
    abstract from: 'a [] -> IObservable<'a>
    abstract interval: int -> IObservable<int>
    abstract zip: 'a IObservable * 'b IObservable -> IObservable<'a * 'b>

Also, I think you shouldn't need to specify the route to node_modules. Webpack or any other module resolution mechanism should be able to find a package node_modules when you don't use a relative path (probably you can omit index.js too):

[<ImportAll("rxjs")>]
let internal rxObservable: IRX = jsNative

[<ImportAll("rxjs/internal/operators")>]
let internal rxOperators: IRXOperators = jsNative

@alfonsogarciacaro You saved the day! Both suggestions worked like a charm. Thank you!
For reference this is the working solution: https://gist.github.com/MecuSorin/67c469e6e55e7f59d03117dce28c1086

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  26Comments

alexfoxgill picture alexfoxgill  路  39Comments

tomcl picture tomcl  路  26Comments

bilkusg picture bilkusg  路  28Comments

et1975 picture et1975  路  25Comments