Code Monkey home page Code Monkey logo

purescript-rxjs's Issues

observable creation is effectful and should be defined as such

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

Allow a Subject to subscribe to an Observable

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

'TypeError: tryCatchTarget.apply is not a function' when trying to use `windowWhen`

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

`unsubscribe` causes runtime exception

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();
  };
}

startWith doesn't work correctly

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 startWithAllor startWithMany.

I've fixed this in my own version, and will gladly send a PR if you decide to go down of these paths. :)

how to subscribe?

I can't fix types when I subscribe like here.

How can one subscribe with subscribe, not subscribeNext?

'TypeError: obs.subscribe is not a function' when calling `never`

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

Add ObservableT Monad transformer

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.

Add operator defaultIfEmpty

There currently seems to be a wrapper for defaultIfEmpty on the js side of things, but none on the purs side of things.

'TypeError: obs.subscribe is not a function' when calling `empty`

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.