@machinat/x-machinat

0.2.0-5 • Public • Published

X-Machinat

Warning: This package is on experimental, the API might frequently change without backward compatibility. Please evaluate the risk before using it on production.

Install

npm install @machinat/x-machinat
# or with yarn
yarn add @machinat/x-machinat

Usage

import { fromApp, conditions, merge } from 'x-machinat';
import { map, filter } from 'x-machinat/operators';

const event$ = fromApp(app);

const [postback$, textMsg$, unknownMsg$] = conditions(events$, [
  isPostback,
  isText,
  () => true,
]);

const intendedMsg$ = textMsg$.pipe(map(recognizeIntent));

const action$ = merge(
  postback$.pipe(
    map(actionFromPostback)
  ),
  intendedMsg$.pipe(
    filter(isAction),
    map(actionFromIntent)
  )
);

action$.pipe(
  map(executeAction),
  map(replyResult)
);

merge(
  unknownMsg$,
  intendedMsg$.filter(not(isAction))
).pipe(map(replyRandomEmoji));

API

WIP.

/@machinat/x-machinat/

    Package Sidebar

    Install

    npm i @machinat/x-machinat

    Weekly Downloads

    0

    Version

    0.2.0-5

    License

    MIT

    Unpacked Size

    46.4 kB

    Total Files

    57

    Last publish

    Collaborators

    • lrills
    • lrills0515