jasonzoladz / purescript-rxjs Goto Github PK
View Code? Open in Web Editor NEWAn un-opinionated PureScript wrapper for RxJS v5.*
License: Other
An un-opinionated PureScript wrapper for RxJS v5.*
License: Other
observable creation is effectful and should be defined as such
Lots of functions like https://pursuit.purescript.org/packages/purescript-rxjs/0.2.0/docs/RxJS.Observable are wrong and work differently regarding if optimisation is on or off.
fromArray :: forall a e. Array a -> Eff (vdom::VDOM|e) (Observable a)
instead of
fromArray :: forall a. Array a -> Observable a
(โ๏ธ edited: remove the BUG suffix)
interval :: forall e. Int -> Eff (vdom::VDOM|e) (Observable Int)
instead of
interval :: Int -> Observable Int
etc
We already have an instance for Semigroup as well as for Alt
and Plus
. Defining an instance would be as simple as adding a mempty = _empty
.
I'd love to see how I could integrate this project into mine :)
Not exactly sure how to do that right now, so any kind of documentation would be nice
Right now when I call
subscribe subject observable
I get the following error:
Could not match type
Record
with type
BehaviorSubject
while trying to match type
{ next :: forall e. a -> Eff e Unit
, error :: forall e. Error -> Eff e Unit
, completed :: forall e. Unit -> Eff e Unit
}
with
BehaviorSubject a
Full stacktrace:
TypeError: tryCatchTarget.apply is not a function
at tryCatcher (/Users/luka/proj/purescript-rxjs/node_modules/rxjs/util/tryCatch.js:6:31)
at WindowSubscriber.openWindow (/Users/luka/proj/purescript-rxjs/node_modules/rxjs/operator/windowWhen.js:115:72)
at new WindowSubscriber (/Users/luka/proj/purescript-rxjs/node_modules/rxjs/operator/windowWhen.js:74:14)
at WindowOperator.call (/Users/luka/proj/purescript-rxjs/node_modules/rxjs/operator/windowWhen.js:59:33)
at Observable.subscribe (/Users/luka/proj/purescript-rxjs/node_modules/rxjs/Observable.js:42:22)
at /Users/luka/proj/purescript-rxjs/output/RxJS.Observable/foreign.js:38:11
at __do (/Users/luka/proj/purescript-rxjs/output/Test.Main/index.js:30:57)
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:269:16
at /Users/luka/proj/purescript-rxjs/output/Test.Unit/foreign.js:23:7
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:214:12
import RxJS.ReplaySubject (just, debounceTime, send, subscribeNext)
import RxJS.Subscription (unsubscribe)
pure { changeObservable : just "" # debounceTime 500
--- ...
{ changeObservable, search } <- readState this
subscription <- subscribeNext search changeObservable
unsubscribe subscription
I put unsubscribe
right after subscribeNext
for testing this issue. Handler search
is working, everything works as expected but unsubscribe
here causes this exception:
TypeError: sub is undefined Subscription.js:10
exports.unsubscribe/< Subscription.js:10
That is:
// module RxJS.Subscription
var Rx = require('rxjs');
exports.unsubscribe = function(sub){
return function(){
sub.unsubscribe();
};
}
Currently startWith
requires an Array
. My thoughts here were, that every item of the Array would be prepended to the Observable, however what actually happens is that just the Array get prepended. This of course completely breaks the type safety and will throw errors at runtime.
I see two solutions right now, either change the type signature to:
foreign import startWith :: forall a. a -> Observable a -> Observable a
or change the underlying JS code to actually parse the array and prepend all the items individually.
We could of course have both as well, with something like startWith
and startWithAll
or startWithMany
.
I've fixed this in my own version, and will gladly send a PR if you decide to go down of these paths. :)
Looks like it's required here:
purescript-rxjs/src/RxJS/Observable.purs
Line 111 in a0ebb53
But if this is needed in tests, maybe a newtype instance would remove the need for it. Otherwise it seems like I can't build this package without this installed.
I can't fix types when I subscribe like here.
How can one subscribe with subscribe, not subscribeNext?
Full stack trace:
TypeError: obs.subscribe is not a function
at /Users/luka/proj/purescript-rxjs/output/RxJS.Observable/foreign.js:38:11
at __do (/Users/luka/proj/purescript-rxjs/output/Test.Main/index.js:33:57)
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:269:16
at /Users/luka/proj/purescript-rxjs/output/Test.Unit/foreign.js:23:7
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:214:12
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:182:25
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:275:5
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
I've noticed that usually when we have observables they're often effectful. FromEvent or create are effectful and really most are, especially when dealing with Ajax or the Dom.
I think a Monad transformer would go a long way to ease those pains and reduce boilerplate.
Pleaseeeee..
Right now we have concat
for semigroup and merge
for Alt
. I think we should make it consistent across type classes. My vote goes for merge
as concat
is rarely used if ever.
There currently seems to be a wrapper for defaultIfEmpty
on the js side of things, but none on the purs
side of things.
full stack trace:
TypeError: obs.subscribe is not a function
at /Users/luka/proj/purescript-rxjs/output/RxJS.Observable/foreign.js:38:11
at __do (/Users/luka/proj/purescript-rxjs/output/Test.Main/index.js:33:57)
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:269:16
at /Users/luka/proj/purescript-rxjs/output/Test.Unit/foreign.js:23:7
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:214:12
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:182:25
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:275:5
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
at /Users/luka/proj/purescript-rxjs/output/Control.Monad.Aff/foreign.js:176:17
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.