UNPKG

@dillonkearns/elm-graphql

Version:

<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">

14 lines (8 loc) 382 B
// @flow import type {Event, Notifier} from "../types"; const getNotifier = (handlerName, data) => observer => observer[handlerName] && observer[handlerName](data); const getHandlerName = event => `on${event}`; const notify = (notifier: Notifier<any>, event: Event, data: any) => notifier.observers.forEach(getNotifier(getHandlerName(event), data)); export default notify;