Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/garronej/evt
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Apr 19, 2020
2 parents 1d7a925 + fde947e commit 38d10ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api/evt/use-effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const evtText = Evt.create("foo");

Evt.useEffect(
text=> console.log(text),
evtText.evtChange.statefulPipe(ctx)
evtText.evtChange.pipe(ctx)
); // Pints "foo"

evtText.state= "bar"; // Prints "bar"
Expand Down
23 changes: 19 additions & 4 deletions docs/api/statefulevt.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ evtColor.state= "BLUE"; //Prints nothing
evtColor.state= "WHITE"; //Prints "BLUE=>WHITE"
```

## `.statefulPipe(...)`
## `.pipe(...)`

Same as [`evt.pipe(...)`](https://docs.evt.land/api/evt/pipe) but return a `StatefulEvt`.
Same as [`evt.pipe(...)`](https://docs.evt.land/api/evt/pipe) but return a `StatefulEvt`. Be aware that the current state of the `StatefulEvt` must be matched by the operator \( if any \) when invoking `.pipe()`, elst an exception will be thrown.

```typescript
import { Evtfrom "evt";
Expand All @@ -96,7 +96,7 @@ type Circle = { 
const evtSelectedCircle = Evt.create<Circle>({ "color": "RED", "radius": 3 });

const evtSelectedCricleColor =
evtSelectedCircle.statefulPipe(circle=> [ cicle.color ]);
evtSelectedCircle.pipe(circle=> [ cicle.color ]);

evtSelectedCircleColor.attach(console.log);
```
Expand Down Expand Up @@ -131,7 +131,7 @@ const evtIsBigAndBlue = Evt.merge([
evtIsBig.evtChange
])
.toStateful()
.statefulPipe(()=> [ evtIsBlue.state && evtIsBig.state ])
.pipe(()=> [ evtIsBlue.state && evtIsBig.state ])
;

console.log(evtIsBigAndBlue.state); // Prints "false"
Expand Down Expand Up @@ -186,3 +186,18 @@ evtTick.post(2); // TS ERROR
postForceChange(wData?: readonly [T]): number;
```

## `.toStateless([ctx])`

Return a stateless copy of the `Evt.`

```typescript
import { Evt } from "evt";

const evtText= Evt.create("foo");

//x is Evt<string>
const x= evtText.toStateless();
```

`evt.toStateless()` is equivalent to `Evt.prototype.pipe.call(evt)`

0 comments on commit 38d10ed

Please sign in to comment.