0.3.0 • Published 4 years ago

@felangel/react-bloc v0.3.0

Weekly downloads
46
License
MIT
Repository
github
Last release
4 years ago

Bloc for React

This package is built to work with bloc.

Bloc Components

BlocBuilder is a React component which requires a Bloc and a builder function. BlocBuilder handles building the component in response to new states. The builder function will potentially be called many times and should be a pure function that returns a component in response to the state.

<BlocBuilder
  bloc={bloc}
  builder={count => {
    return <p>{count}</p>
  }}
/>

If you want fine-grained control over when the builder function is called you can provide an optional condition to BlocBuilder. The condition takes the previous bloc state and current bloc state and returns a boolean. If condition returns true, builder will be called with currentState and the widget will rebuild. If condition returns false, builder will not be called with currentState and no rebuild will occur.

<BlocBuilder
  bloc={bloc}
  condition={(previousState, currentState) => {
    return (previousState + currentState) % 3 === 0
  }}
  builder={count => {
    return <p>{count}</p>
  }}
/>

Maintainers

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

5 years ago