
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
A small push-pull based signal library based on alien-signals algorithm.
A small push-pull based signal library based on alien-signals algorithm.
Was created as reactivity system for nanoviews and Kida.
import { signal, computed, effect } from 'agera'
const $count = signal(1)
const $doubleCount = computed(() => count() * 2)
effect(() => {
console.log(`Count is: ${$count()}`);
}) // Console: Count is: 1
console.log($doubleCount()) // 2
$count(2) // Console: Count is: 2
console.log($doubleCount()) // 4
Install
•
API
•
Why?
pnpm add -D agera
# or
npm i -D agera
# or
yarn add -D agera
Signal is a basic store type. It stores a single value.
import { signal, update } from 'agera'
const $count = signal(0)
$count($count() + 1)
// or
update($count, count => count + 1)
To watch signal changes, use the effect
function. Effect will be called immediately and every time the signal changes.
import { signal, effect } from 'agera'
const $count = signal(0)
const stop = effect(() => {
console.log('Count:', $count())
return () => {
// Cleanup function. Will be called before effect update and before effect stop.
}
})
// later you can stop effect
stop()
Computed is a signal that computes its value based on other signals.
import { computed } from 'agera'
const $firstName = signal('John')
const $lastName = signal('Doe')
const $fullName = computed(() => `${$firstName()} ${$lastName()}`)
console.log($fullName()) // John Doe
effectScope
effectScope
creates a scope for effects. It allows to stop all effects in the scope at once.
import { signal, effectScope, effect } from 'agera'
const $a = signal(0)
const $b = signal(0)
const stop = effectScope(() => {
effect(() => {
console.log('A:', $a())
})
effectScope(() => {
effect(() => {
console.log('B:', $b())
})
})
})
stop() // stop all effects
Also there is a possibility to create a lazy scope.
import { signal, effectScope, effect } from 'agera'
const $a = signal(0)
const $b = signal(0)
// All scopes will run immediately, but effects run is delayed
const start = effectScope(() => {
effect(() => {
console.log('A:', $a())
})
effectScope(() => {
effect(() => {
console.log('B:', $b())
})
})
}, true) // marks scope as lazy
// start all effects
const stop = start()
stop() // stop all effects
One of main feature of Agera is that every signal can be active or inactive. It allows to create lazy signals, which will use resources only if signal is really used in the UI.
onActivate
lifecycle method adds callback for activation and deactivation events.
import { signal, onActivate, effect } from 'agera'
const $count = signal(0)
onActivate($count, (active) => {
console.log('Signal is', active ? 'active' : 'inactive')
})
// will activate signal
const stop = effect(() => {
console.log('Count:', $count())
})
// will deactivate signal
stop()
To batch updates you should wrap signal updates between startBatch
and endBatch
.
import { signal, startBatch, endBatch, effect } from 'agera'
const $a = signal(0)
const $b = signal(0)
effect(() => {
console.log('Sum:', $a() + $b())
})
// Effects will be called only once
startBatch()
$a(1)
$b(2)
endBatch()
To skip tracking of signal changes you should wrap signal calls between pauseTracking
and resumeTracking
.
import { signal, pauseTracking, resumeTracking, effect } from 'agera'
const $a = signal(0)
const $b = signal(0)
effect(() => {
const a = $a()
pauseTracking()
const b = $b()
resumeTracking()
console.log('Sum:', a + b)
})
// Will trigger effect run
$a(1)
// Will not trigger effect run
$b(2)
morph
methods allows to create signals that can change their getter and setter on the fly.
import { signal, morph, $$get, $$set, $$source } from 'agera'
const $string = signal('')
// Debounce signal updates
const $debouncedString = morph($string, {
[$$set]: debounce($string, 300)
})
// Lazy initialization
const $lazyString = morph($string, {
[$$get]() {
this[$$set]('Lazy string')
this[$$get] = this[$$source]
return 'Lazy string'
}
})
isSignal
isSignal
method checks if the value is a signal.
import { isSignal, signal } from 'agera'
isSignal(signal(1)) // true
Key differences from alien-signals:
effectScope
. Agera has a possibility to put effect scope inside another effect scope. Also there is a possibility to create a lazy scope.FAQs
A small push-pull based signal library based on alien-signals algorithm.
The npm package agera receives a total of 8 weekly downloads. As such, agera popularity was classified as not popular.
We found that agera demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.