
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
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 2 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
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.