Skip to content

Instantly share code, notes, and snippets.

View njj's full-sized avatar
:octocat:

Nick njj

:octocat:
  • Peerspace
  • Florida
View GitHub Profile
@njj
njj / actions.js
Created August 24, 2016 15:02 — forked from andrewmclagan/actions.js
react-redux-universal-hot-example
export function login(loginHandle, password) {
return {
types: [LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE],
promise: (api) => api.post('/auth/login', { login: loginHandle, password }).then(response => {
setAuthCookie(response.token); // side effect pre success dispatch
return response;
}),
then: (response) => {
postLoginRedirect(browserHistory.push, response.user, response.organisation); // side effect post success dispatch
},
@njj
njj / Functional-Programming.md
Last active December 10, 2015 16:22 — forked from ktilcu/Functional-Programming.md
Functional programming is actually good for javascript developers

Rules

  • no side effects (function can't rely on anything not provided to it)
  • inputs and outputs

In Practice

  • Nested functions are always an indication of complexity

Creates Functions that are

  • Easy to read
  • Easy to reuse