
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
@bloc-state/bloc
Advanced tools
@bloc-state/bloc is a state management library implementing the BLoC pattern that was first introduced
by google at DartConf in 2018. This library conforms to the
modern Dart Bloc library v8.x api.
npm install @bloc-state/bloc rxjs
export class CounterCubit extends Cubit<number> {
constructor() {
super(0) // pass initial state to super constructor
}
increment() {
this.emit((state) => state + 1)
}
increment() {
this.emit((state) => state - 1)
}
}
const counterCubit = new CounterCubit()
console.log(counterCubit.state) // 0
counterCubit.increment()
console.log(counterCubit.state) // 1
// cubit is closed and disposed, it will no longer emit new state and all observers will be unsubscribed
cubit.close()
export class AppBlocObserver extends BlocObserver {
override onCreate(bloc: BlocBase<any>): void {
console.log(`onCreate: ${bloc.constructor.name}`)
}
override onError(bloc: BlocBase<any>, error: any): void {
console.log(`onError: ${bloc.constructor.name}`, error)
}
override onChange(bloc: BlocBase<any>, change: Change<any>): void {
console.log(`onChange: ${bloc.constructor.name}`, change)
}
override onClose(bloc: BlocBase<any>): void {
console.log(`onClose: ${bloc.constructor.name}`)
}
}
// main.tsx
// composition root of your application
Bloc.observer = AppBlocObserver()
/// The events which `CounterBloc` will react to.
abstract class CounterEvent extends BlocEvent {}
class CounterIncrementEvent extends CounterEvent {}
class CounterDecrementEvent extends CounterEvent {}
export class CounterBloc extends Bloc<CounterEvent, number> {
constructor() {
super(new CounterState(0))
this.on(CounterIncrementEvent, (event, emit) => emit((state) => state + 1))
this.on(CounterDecrementEvent, (event, emit) => emit((state) => state - 1))
}
}
async function main() {
const delay = (n) => new Promise((resolve) => setTimeout(resolve, n))
const counterBloc = new CounterBloc()
console.log(counterBloc.state) // 0
counterBloc.add(new CounterIncrementEvent())
// wait for next tick in event loop
await delay(0)
console.log(counterBloc.state) // 1
counterBloc.close() // close the bloc when no longer needed
}
FAQs
The core library for bloc-state.
We found that @bloc-state/bloc 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.