@machinat/x-machinat
v0.2.0-5
Published
Reactive programming library for Machinat.js
Downloads
1
Readme
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.