import { Observable } from 'rxjs/Observable' ; import { compose } from '@ngrx/core/compose' ; export interface Hook < T > { apply ( input$ ) : Observable < T > ; } export const identity = { apply ( input$ ) { return input$ ; } } ; export function composeHooks < T > ( hooks ) { const allHooks = ! hooks ? [ identity ] : [ identity , ... hooks ] ; const resolved = allHooks . map ( hook => ( input$ ) => hook . apply ( input$ ) ) ; return compose ( ... resolved ) ; }