Skip to content

Commit

Permalink
style: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jul 5, 2018
1 parent c449484 commit 57b8f65
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fetch_libdefs": "flow-typed install lodash@4.17.10",
"lint": "standard src/**/*.js test/**/*.js",
"mocha": "nyc mocha --opts .mocha.opts && nyc report --reporter=text-lcov > ./coverage/lcov.info",
"test": "npm run flow_coverage && npm run mocha",
"test": "npm run lint && npm run flow_coverage && npm run mocha",
"docs": "npm run build_es6 && docma --require flow-remove-types/register -c ./docma.json",
"test_with_report": "npm test && npm run codeclimate_push && npm run coveralls_push",
"codeclimate_push": "codeclimate-test-reporter < ./coverage/lcov.info",
Expand Down
2 changes: 1 addition & 1 deletion src/bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class Bus implements IBus {

this.dispatcher
.on(`${this.scope}${HASH_UPDATE}`, ({state: {stack}}: IHandlerArgs) => ({hash: Math.random(), stack}))
.on(`${this.scope}${EMIT_SIGNAL}`, ({state: {stack, hash}, signal}: IHandlerArgs) => ({hash, stack: signal ? stack.concat(signal): stack}))
.on(`${this.scope}${EMIT_SIGNAL}`, ({state: {stack, hash}, signal}: IHandlerArgs) => ({hash, stack: signal ? stack.concat(signal) : stack}))
.on(`${this.scope}${ERASE_SIGNAL}`, ({state: {stack, hash}, filter}: IHandlerArgs) => {
if (!filter) {
return {stack, hash}
Expand Down
111 changes: 51 additions & 60 deletions src/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

export type IFilterValue = | string | RegExp | Function | any

export type IAction = {
type: string;
signal: ?ISignal;
filter: ?IFilter;
export type ISignalOpts = {
name: string;
data: ?any;
ttl: ?number;
}
export interface ISignal {
constructor(opts: ISignalOpts): ISignal;
name: string;
data: any;
ttl: number;
expiresAt: number;
}
export type ISignalStack = Array<ISignal>

export interface IFilterPredicate {
(signal: ISignal): boolean
Expand All @@ -18,65 +26,49 @@ export interface IFilter {
fn: IFilterPredicate;
}

export type ISignalStack = Array<ISignal>

export interface ISignal {
constructor(opts: ISignalOpts): ISignal;
name: string;
data: any;
ttl: number;
expiresAt: number;
}

export type ISignalOpts = {
name: string;
data: ?any;
ttl: ?number;
export type IAction = {
type: string;
signal: ?ISignal;
filter: ?IFilter;
}

export type ISignalState = {
stack: ISignalStack;
hash: number;
}

export type IDispatch = {
(action: IAction): IAction
}

export type IState = any

export interface IStore {
dispatch: IDispatch;
getState(): IState
}

export type IState = any

export type IEntireState = {
[key: string]: any;
}

export type IDispatch = {
(action: IAction): IAction
}

export interface IBus {
scope: string;
store: IStore;
dispatcher: IDispatcher;

constructor(): IBus;
configure(opts: IBusOpts): IBus;
emit(name: string, data?: ?any, ttl?: ?number, silent: ?ISilent): void;
listen(value: IFilterValue, silent: ?ISilent, skipCompact: ?boolean): ISignalStack;
erase(value: IFilterValue, silent: ?ISilent): ISignalStack;
capture(value: IFilterValue, silent: ?ISilent): ISignalStack;
connect(component: IReactComponent): IReactComponent;
getReducer(): IReducer;
getScope(): string;
hashUpdate(): void
}
export type IReactComponent = any
export type ISilent = boolean

export type IBusOpts = {
store: IStore
}

export type IReactComponent = any

export type IHandlerArgs = {
state: ISignalState;
event: string;
signal: ?ISignal;
filter: ?IFilter;
}
export interface IHandler {
(input: IHandlerArgs): ISignalState
}
export type IHandlerMap = {
[key: string]: IHandler
}
export interface IDispatcher {
dispatch: IDispatch;
handlers: IHandlerMap;
Expand All @@ -87,24 +79,23 @@ export interface IDispatcher {
reducer(state: IState, action: IAction): IState;
}

export interface IHandler {
(input: IHandlerArgs): ISignalState
}

export type IHandlerMap = {
[key: string]: IHandler
}

export type IHandlerArgs = {
state: ISignalState;
event: string;
signal: ?ISignal;
filter: ?IFilter;
}

export interface IReducer {
reduce(state: any): any
}

export type ISilent = boolean
export interface IBus {
scope: string;
store: IStore;
dispatcher: IDispatcher;

constructor(): IBus;
configure(opts: IBusOpts): IBus;
emit(name: string, data?: ?any, ttl?: ?number, silent: ?ISilent): void;
listen(value: IFilterValue, silent: ?ISilent, skipCompact: ?boolean): ISignalStack;
erase(value: IFilterValue, silent: ?ISilent): ISignalStack;
capture(value: IFilterValue, silent: ?ISilent): ISignalStack;
connect(component: IReactComponent): IReactComponent;
getReducer(): IReducer;
getScope(): string;
hashUpdate(): void
}
1 change: 1 addition & 0 deletions test/dispatcher.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-unused-expressions: 0 */
import chai from 'chai'
import chaiSpies from 'chai-spies'
import Dispatcher from '../src/dispatcher'
Expand Down
3 changes: 2 additions & 1 deletion test/filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-unused-expressions: 0 */
import chai from 'chai'
import Filter from '../src/filter'

Expand All @@ -22,7 +23,7 @@ describe('filter', () => {
})

it('from predicate', () => {
const value = ({name}) => name.length ===3
const value = ({name}) => name.length === 3
const filter = new Filter(value)

expect(filter.value).to.equal(value)
Expand Down

0 comments on commit 57b8f65

Please sign in to comment.