Skip to content

Instantly share code, notes, and snippets.

View iktash's full-sized avatar

Illia Kolodiazhnyi iktash

  • Dublin, Ireland
View GitHub Profile
@iktash
iktash / functionalDispatch.js
Created October 22, 2018 06:50
A tiny example of an application state management done in a fully functional manner
const getDispatch = (initialState, render) => {
let stateContainer = Container.of(initialState);
const updateState = action => new IO(() => {
stateContainer = stateContainer.map(action);
return stateContainer;
});
return action => {
const sideEffects = pipe(
//Uses the https://github.com/github-tools/github library under the hood and exposes it as `gh` property
function GithubAPI(auth) {
let repo;
let filesToCommit = [];
let currentBranch = {};
let newCommit = {};
//the underlying library for making requests
let gh = new GitHub(auth);