New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bloc-react

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloc-react

[comment]: <> ([Coverage: 100%])

  • 0.0.14-2
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

BLoC React

TypeScript BLoC pattern implementation for react using RxJS and heavily inspired by flutter_react - https://bloclibrary.dev

The BLoC Pattern (Business Logic Component) is a battle-tested design pattern for state management coming from Flutter and Dart. It tries to separate business logic from UI as much as possible while still being simple and flexible.

Everything revolves around subjects which are native to Dart, for JS there is a solid implementation by RxJS.

Quickstart

[TODO: Add plain JS examples]

1. Create a new Bloc/Cubit

// CounterCubit.ts
export default class CounterCubit extends Cubit<number> {
  increment = (): void => {
    this.emit(this.state + 1);
  };
}

2. Create a new BlocReact instance and export useBloc from it

// state.ts
const state = new BlocReact([new CounterCubit(0)]);
export const { useBloc } = state;

3. Use the hook to access the state and class methods

// CounterButton.tsx
import { useBloc } from "../state";

export default function CounterButton() {
  const [count, { increment }] = useBloc(CounterCubit);
  return <button onClick={() => increment()}>count is: {count}</button>;  
}

Documentation

[TODO]

BlocReact

[TODO]

Bloc

[TODO]

Cubit

[TODO]

BlocObserver

[TODO]

FAQs

Package last updated on 05 May 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc