How to use the ferp.types function in ferp

To help you get started, we’ve selected a few ferp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ferp-js / ferp / examples / game-input / reducers / gamePadReducer.js View on Github external
const effect = (() => {
          if (isGamePadFree && playerNeedsGamePadIndex) {
            return ferp.types.Effect.immediate({
              type: 'ASSIGN_GAMEPAD_INDEX',
              playerId: playerNeedsGamePadIndex.id,
              gamePadIndex: message.gamePadIndex,
            });
          }
          const player = players
            .find(p => p.sourceType === 'gamepad' && p.gamePadIndex === message.gamePadIndex);

          if (!player) return none();

          return inputEffect(true, player.id, message.button);
        })();
github ferp-js / ferp / examples / http-server / router.js View on Github external
nextState,
          ferp.types.Effect.map([
            effect,
            logEffect(new Date(), message.request, parsed, matcher),
          ])
        ]
      }

    case 'LOG':
      return [
        { ...state, logs: [message.log].concat(state.logs) },
        ferp.types.Effect.none(),
      ];

    default:
      return [state, ferp.types.Effect.none()];
  }
}
github ferp-js / ferp / examples / http-server / router.js View on Github external
const router = (routes) => (message, state) => {
  switch (message.type) {
    case 'ROUTE':
      const parsed = url.parse(message.request.url);
      const matcher = requestToMatcher(message.request, parsed);
      const handler = routes[matcher] || routes['GET /not-found'];
      if (handler) {
        const [nextState, effect] = handler(message, state, parsed);
        return [
          nextState,
          ferp.types.Effect.map([
            effect,
            logEffect(new Date(), message.request, parsed, matcher),
          ])
        ]
      }

    case 'LOG':
      return [
        { ...state, logs: [message.log].concat(state.logs) },
        ferp.types.Effect.none(),
      ];

    default:
      return [state, ferp.types.Effect.none()];
  }
}

ferp

Build functional and pure applications in NodeJS and the Browser!

MIT
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis