
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
callbag-expr
Advanced tools
Create expressions based on callbags.
npm i callbag-expr
👉 Expressions with callbags:
import interval from 'callbag-interval'
import pipe from 'callbag-pipe'
import subscribe from 'callbag-subscribe'
import expr from 'callbag-expr'
const a = interval(1000)
pipe(
expr($ => 'Hellow: ' + $(a, 0)),
subscribe(console.log)
)
👉 Conditional expressions:
import interval from 'callbag-interval'
import pipe from 'callbag-pipe'
import subscribe from 'callbag-subscribe'
import expr from 'callbag-expr'
const a = interval(1000)
const b = interval(600)
const c = interval(3000)
pipe(
expr($ => {
if($(c, 0) % 2) return 'A = ' + $(a)
else return 'B = ' + $(b)
}),
subscribe(console.log)
)
👉 Passive tracking, i.e. using latest value from callbag without re-evaluating when it emits:
import interval from 'callbag-interval'
import pipe from 'callbag-pipe'
import subscribe from 'callbag-subscribe'
import expr from 'callbag-expr'
const a = interval(1000)
const b = interval(300)
pipe(
expr(($, _) => $(a) + _(b)),
subscribe(console.log)
)
⚠️⚠️ Don't create new callbags in the expression:
// WRONG:
expr($ => $(interval(1000)));
// CORRECT:
const i = interval(1000);
expr($ => $(i));
⚠️⚠️ Make sure your callbags have initial value, or provide initial value. If you don't, $(a)
might default to undefined
(so take that into account).
// WRONG:
const a = interval(1000);
expr($ => $(a)); // --> initially will be `undefined`
// CORRECT:
const a = interval(1000);
expr($ => $(a, 0)); // --> initially will be 0
// CORRECT:
const a = makeBehaviorSubject(42);
expr($ => $(a)); // --> initially will be 42
⚠️⚠️ Make sure some callbag is actively tracked:
// WRONG:
const a = interval(1000);
const b = interval(1000);
//
// --> a is not actively tracked, b is also not tracked initially,
// --> so the expression is never re-evaluated.
//
expr($ => _(a, 0) > 5 ? $(b) : 32);
Play nice and respectful. Useful commands for development:
git clone https://github.com/loreanvictor/callbag-expr.git
npm i # --> install dependencies
npm start # --> run samples/index.ts
npm test # --> run tests
npm run cov:view # --> view coverage
Inspired by RxJS Autorun.
FAQs
Expressions with callbags
The npm package callbag-expr receives a total of 6 weekly downloads. As such, callbag-expr popularity was classified as not popular.
We found that callbag-expr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.