
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@suku/typed-rx-emitter
Advanced tools
.on()
are defined.emit()
are defined# Using Yarn:
yarn add typed-rx-emitter rxjs
# Using NPM:
npm install typed-rx-emitter rxjs --save
# Using Yarn:
yarn add typed-rx-emitter@^0.3
# Using NPM:
npm install typed-rx-emitter@^0.3 --save
import { Emitter } from 'typed-rx-emitter'
// Enumerate messages
type Messages = {
INCREMENT_COUNTER: number
OPEN_MODAL: boolean
}
const emitter = new Emitter<Messages>()
// Listen on an event (basic)
emitter
.on('OPEN_MODAL')
.subscribe(_ => console.log(`Change modal visibility: ${_}`)) // _ is a boolean
// Listen on an event (advanced)
import { debounceTime, filter } from 'rxjs/operators'
emitter
.on('INCREMENT_COUNTER')
.pipe(
filter(_ => _ > 3), // _ is a number
debounceTime(100)
)
.subscribe(_ => console.log(`Counter incremented to ${_}`)) // _ is a number
// Listen on all events
emitter
.all()
.subscribe(() => console.log('Something changed'))
// Trigger an event - throws a compile time error unless id and value are set, and are of the right types
emitter.emit('OPEN_MODAL', true)
// Event is misspelled - throws a compile time error
emitter.emit('INCREMENT_CONTER')
See a complete browser usage example here.
Emitter
takes an optional options
argument. options
is an object, and each key in the object is optional:
Option | Default | Description |
---|---|---|
Error | CyclicalDependencyError | Custom Error subclass for cycle warning |
isDevMode | false | Perform dynamic analysis to warn about cycles? |
npm test
FAQs
Typesafe Rx-based emitter
We found that @suku/typed-rx-emitter 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.