0.6.0 • Published 3 years ago

@machinat/stream v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Machinat Stream

Reactive programming stream for handling events in back-end.

⚠ This package is still on early experimental. There might be breaking changes in the future for supporting cluster. You can check the future road map here.

Install

npm install @machinat/stream
# or with yarn
yarn add @machinat/stream

Docs

Check the Reactive Programming document and the package reference.

Example

import { makeContainer, IntentRecognizer } from '@machinat/core';
import { fromApp } from '@machinat/stream';
import { map, filter } from '@machinat/stream/operators';
import app from './app';

const event$ = fromApp(app);

const textMsg$ = events$.pipe(
  filter(({ event }) => event.type === 'text'),
  map(
    makeContainer({ deps: [IntentRecognizer] })(
      (recognizer) =>
        async (context) => {
          const { channel, text } = context.event;
          const intent = await recognizer.detectText(channel, text);
          return { ...context, intent };
        }
    )
  )
);

textMsg$.subscribe(async ({ intent, reply }) => {
  const action = intent.type;
  if (action) {
    await reply(`start ${action}...`);
  }
});
0.6.0

3 years ago

0.6.0-canary.0

3 years ago

0.6.0-beta.0

3 years ago

0.5.0-beta.11

4 years ago

0.5.0-beta.12

4 years ago

0.5.0-beta.10

4 years ago

0.5.0-beta.36

3 years ago

0.5.0-beta.14

4 years ago

0.5.0-beta.41

3 years ago

0.5.0-beta.44

3 years ago

0.5.0

3 years ago

0.5.0-beta.3

4 years ago

0.5.0-beta.2

4 years ago

0.5.0-beta.1

4 years ago

0.5.0-beta.0

4 years ago

0.4.1-alpha.44

4 years ago

0.4.1-alpha.39

4 years ago

0.4.1-alpha.34

4 years ago

0.4.1-alpha.33

4 years ago

0.4.1-alpha.31

4 years ago

0.4.1-alpha.29

4 years ago

0.4.1-alpha.28

4 years ago

0.4.1-alpha.27

4 years ago

0.4.1-alpha.24

4 years ago

0.4.1-alpha.18

4 years ago

0.4.1-alpha.5

4 years ago

0.4.1-alpha.3

4 years ago

0.4.1-alpha.1

4 years ago

0.4.0-beta.4

4 years ago

0.4.0-beta.1

4 years ago