Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥Remove transform example from event docs. #847

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions www/docs/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ place, but the actual consuming of the stream of clicks can happen anywhere.
[channel]: https://deno.land/x/effection/mod.ts?s=Channel
[signal]: https://deno.land/x/effection/mod.ts?s=Signal
[createSignal]: https://deno.land/x/effection/mod.ts?s=createSignal
[filter]: https://deno.land/x/effection/mod.ts?s=filter
[map]: https://deno.land/x/effection/mod.ts?s=map
[pipe]: https://deno.land/x/effection/mod.ts?s=pipe
[fp-ts.pipe]: https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe
[lodash.flow]: https://lodash.com/docs/4.17.15#flow
[close-event]: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
35 changes: 0 additions & 35 deletions www/docs/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,8 @@ await main(function*() {
});
```

This allows us not only to represent the events that fire on an event
target as [Effection streams](./collections), but it also lets us use
all of the Stream operations to transform these streams:

``` javascript
import { main, pipe, map, on, filter, first } from 'effection';

await main(function*() {
let socket = new WebSocket('ws://localhost:1234');

let start = pipe(
on(socket, 'message'),
map(event => JSON.parse(event.data)),
filter(data => data.type === 'start'),
first,
);

let startEvent = yield* start;

console.log('got start message!: ' + startEvent);
});
```

In this code, we very concisely:

1. start with a stream of message events
2. [map][map] that stream into a stream of parsed JSON payloads
3. [filter][filter] the mapped stream to only be "start" events
4. take the filterd stream and return an operation for the first event

As a result, `start` is an operation that will yield the payload from the first
"start" event from the websocket!

[wscode]: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
[childprocess]: https://nodejs.org/api/child_process.html#child_process_class_childprocess
[once]: https://deno.land/x/effection/mod.ts?s=once
[on]: https://deno.land/x/effection/mod.ts?s=on
[map]: https://deno.land/x/effection/mod.ts?s=map
[filter]: https://deno.land/x/effection/mod.ts?s=filter
[event-target]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
Loading