0.8.0 • Published 2 years ago

@sociably/stream v0.8.0

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

Sociably 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 @sociably/stream
# or with yarn
yarn add @sociably/stream

Docs

Check the Reactive Programming document and the package reference.

Example

import { makeContainer, IntentRecognizer } from '@sociably/core';
import { fromApp } from '@sociably/stream';
import { map, filter } from '@sociably/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.9.0-alpha.0

2 years ago

0.9.0-alpha.4

2 years ago

0.9.0-alpha.26

2 years ago

0.8.0

2 years ago

0.8.0-alpha.28

2 years ago

0.8.0-alpha.10

2 years ago

0.8.0-alpha.8

2 years ago

0.8.0-alpha.0

3 years ago

0.8.0-alpha.1

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago