@ambientlight/bs-rx
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "@ambientlight/bs-rx", | ||
"namespace": false, | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"sources": [ | ||
@@ -6,0 +6,0 @@ { |
{ | ||
"name": "@ambientlight/bs-rx", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "bucklescript bindings for RxJs v7", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,1 +1,6 @@ | ||
[![STATUS](https://github.com/ambientlight/bs-rx/workflows/Deploy%20Docs/badge.svg)](https://github.com/ambientlight/bs-rx/actions) | ||
[![VERSION](https://img.shields.io/npm/v/@ambientlight/bs-rx)](https://www.npmjs.com/package/@ambientlight/bs-rx) | ||
[![LICENSE](https://img.shields.io/github/license/ambientlight/bs-rx?t)](https://github.com/ambientlight/bs-rx/blob/master/LICENSE) | ||
[![ISSUES](https://img.shields.io/github/issues/ambientlight/bs-rx)](https://github.com/ambientlight/bs-rx/issues) | ||
# bs-rx | ||
@@ -30,5 +35,4 @@ Bucklescript bindings for [rxjs v7(alpha)](https://github.com/ReactiveX/rxjs) | ||
|> Rx.Operators.mergeMap(`Observable((x, _idx) => | ||
Rx.interval(~period=1000, ()) | ||
|> Rx.Operators.map((i, _idx) => string_of_int(i) ++ x)), | ||
()) | ||
Rx.interval(~period=1000) | ||
|> Rx.Operators.map((i, _idx) => string_of_int(i) ++ x))) | ||
|> Rx.Observable.subscribe(~next=x=>Js.log(x)); | ||
@@ -56,12 +60,18 @@ ``` | ||
You may find marble testing handy to test your rxjs logic. Marble string syntax allow your to specify rxjs events(such as emissions, subscription points) over virtual time that progresses by frames(denoted by `-`). You can use it to express the expected behavior of your observable sequences as strings and compare them with `Rx.Observable.t('a)` instances you are testing. You need to initialize `TestScheduler.t` with a function that can perform deep comparison (such as `BsMocha.Assert.deep_equal`), then put your marble tests inside `ts |> TestScheduler.run(_r => ...)`. Asynchronous operators usually take `~scheduler` parameter, pass `TestScheduler.t` instance to them. The next example illustrates it, also you may want to refer to rxjs [marble diagrams documentation](https://rxjs-dev.firebaseapp.com/guide/testing/marble-testing). | ||
You may find marble testing handy to test your rxjs logic. Marble string syntax allows you to specify rxjs events(such as emissions, subscription points) over virtual time that progresses by frames(denoted by `-`). You can use it to express the expected behavior of your observable sequences as strings and compare them with `Rx.Observable.t('a)` instances you are testing. You need to initialize `TestScheduler.t` with a function that can perform deep comparison (such as `BsMocha.Assert.deep_equal`), then put your marble tests inside `ts |> TestScheduler.run(_r => ...)`. Asynchronous operators usually take `~scheduler` parameter, pass `TestScheduler.t` instance to them. The next example illustrates it, also you may want to refer to rxjs [marble diagrams documentation](https://rxjs-dev.firebaseapp.com/guide/testing/marble-testing). | ||
```reason | ||
open Jest; | ||
open Rx.Testing; | ||
open TestScheduler; | ||
//... | ||
test("timeInterval: should record the time interval between source elements", () => { | ||
let ts = TestScheduler.create(~assertDeepEqual=BsMocha.Assert.deep_equal); | ||
ts |> TestScheduler.run(_r => { | ||
ts |> run(_r => { | ||
// subscribe in 6th frame, 4 emissions: b, c, d, e | ||
let e1 = ts |> hot("--a--^b-c-----d--e--|"); | ||
let e1subs = [|"^--------------!"|]; | ||
let expected = "-w-x-----y--z--|"; | ||
let e1subs = [|"^--------------!"|]; | ||
let expected = "-w-x-----y--z--|"; | ||
// expected values in w, x, y, z emissions | ||
@@ -72,3 +82,3 @@ let values = { "w": 1, "x": 2, "y": 6, "z": 3 }; | ||
|> HotObservable.asObservable | ||
|> Rx.Operators.timeInterval(~scheduler=ts|.TestScheduler.asScheduler, ()) | ||
|> Rx.Operators.timeInterval(~scheduler=ts|.TestScheduler.asScheduler) | ||
|> Rx.Operators.map((x, _idx) => x |. Rx.TimeInterval.intervalGet); | ||
@@ -96,5 +106,5 @@ | ||
You can also build docs via bsdocs. If you have forked this repo, the pushes to master should spin the github actions workflow that rebuild the github pages docs with workflow available at [deploy_docs.yml](https://github.com/ambientlight/bs-rx/blob/master/.github/workflows/deploy_docs.yml). (You will need to set `GH_PAGES_TOKEN` for github pages deployment to work). | ||
You can also generate docs via [bsdoc](https://github.com/reuniverse/bsdoc). If you have forked this repo, the pushes to master should spin the github actions workflow that rebuild the github pages docs with workflow available at [deploy_docs.yml](https://github.com/ambientlight/bs-rx/blob/master/.github/workflows/deploy_docs.yml). (You will need to set `GH_PAGES_TOKEN` for github pages deployment to work). | ||
If you want to generate docs in local make sure you have opam installed with ocaml version matching the ocaml version used in your `bs-platform` (`4.02.3+buckle-master` for bs-platform@5.2.1). | ||
If you want to generate docs in local make sure you have [bsdoc](https://github.com/reuniverse/bsdoc) built against ocaml version matching the ocaml version used in your `bs-platform` (`4.02.3+buckle-master` for bs-platform@5.2.1). | ||
@@ -105,2 +115,2 @@ ``` | ||
For osx, you can use the npm installation of bsdoc, but for linux-based distros, you would need to build bsdoc from source for now. | ||
For osx, you can use the npm installation of bsdoc(corresponds to bs-platform 6), but for linux-based distros, you would need to build bsdoc from source for now. |
Sorry, the diff of this file is not supported yet
250502
37
112