ryardley / ts-bus

A lightweight JavaScript/TypeScript event bus to help manage your application architecture.
MIT License
137 stars 8 forks source link

Breaking Change: Configuration syntax #35

Closed ryardley closed 5 years ago

ryardley commented 5 years ago

This PR provides a draft of the configuration syntax:

This makes useBusReducer more inline with React's useReducer which should be more intuitive for new users of the library.

import {useBusReducer} from 'ts-bus/react';

// The output shares the exact signature of the React equivalent
// This would be a breaking change 
const state = useBusReducer(reducer, initState, init);
import {useBusReducer} from 'ts-bus/react';

// Create a configured useReducer function
const useReducer = useBusReducer.configure({subscriber});

// The output shares the exact signature of the React equivalent but with the configuration applied
const state = useReducer(reducer, initState, init);

This also acts as preparation for these PRs:

codecov[bot] commented 5 years ago

Codecov Report

Merging #35 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #35   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           6      6           
  Lines          66     74    +8     
  Branches       11     11           
=====================================
+ Hits           66     74    +8
Impacted Files Coverage Δ
src/EventBus.ts 100% <ø> (ø) :arrow_up:
src/useBusState.ts 100% <100%> (ø) :arrow_up:
src/useBusReducer.ts 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6352a2c...1f96fd8. Read the comment docs.