ryardley / ts-bus

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

Add predicate filter #14

Closed ryardley closed 5 years ago

ryardley commented 5 years ago

This PR adds the ability to use a predicate function to ts-bus.

const isSharedAndLocalEvent = event =>
  /^shared\./.test(event.type) && !(event.meta && event.meta.remote);

bus.subscribe(isSharedAndLocalEvent, event => {
  // ...
});
codecov[bot] commented 5 years ago

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #14   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          17     26    +9     
  Branches        2      6    +4     
=====================================
+ Hits           17     26    +9
Impacted Files Coverage Δ
src/EventBus.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 c766f6e...18c2c94. Read the comment docs.