Skip to content

Instantly share code, notes, and snippets.

@busypeoples
busypeoples / Simplified-Redux-Reducers.js
Created January 2, 2018 23:21
Simplified Redux Reducers
import Maybe from 'folktale/maybe';
const Inc = 'Inc';
const Dec = 'Dec';
const IncBy = 'IncBy';
const IncFn = state => state + 1;
const DecFn = state => state - 1;
const IncByFn = (state, action) => state + action.incBy;
@busypeoples
busypeoples / ReactGame.js
Last active January 16, 2018 08:10
ReactGame Example: React + Flow
// @flow
import React from 'react';
import { render } from 'react-dom';
type Field = 0 | 1;
type Position = [Field, Field, Field, Field];
type Unit = [Position, Position, Position, Position];
@busypeoples
busypeoples / Game.re
Last active January 7, 2018 22:08
ReasonML Game
type field =
| O
| X;
type position = (field, field, field, field);
type unit = (position, position, position, position);
type units = list(unit);
@busypeoples
busypeoples / Loader.js
Created November 4, 2017 13:09
Loader Implementation
import React from 'react';
import daggy from 'daggy';
// Inspired by:
// "Slaying a UI Antipattern in Fantasyland" @thinkfunctional
// https://medium.com/javascript-inside/slaying-a-ui-antipattern-in-fantasyland-907cbc322d2a
// "Use a Render Prop!"
// https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce @mjackson
const fakeFetch = () =>
new Promise((res, rej) => {
setTimeout(
() =>
res([
{ id: 1, name: 'foo' },
{ id: 2, name: 'bar' },
{ id: 3, name: 'baz' }
]),
1000
@busypeoples
busypeoples / UnderstandingReducer.re
Last active November 11, 2018 15:22
Understanding Reducer in ReasonML
let se = ReasonReact.stringToElement;
type state = int;
type actions =
| Inc
| IncWithSideEffect
| SideEffect
| DoNothing
| SilentIncUpdate
@busypeoples
busypeoples / README.md
Last active October 28, 2020 04:34
Loader

Loader

Introduction

Minimal loader with state management capabilities.

Checkout out the demo.

Setup

Make sure to add a .babelrc file:

@busypeoples
busypeoples / IntroductionToFlow.md
Last active June 29, 2020 08:22
Introduction To Flow

Introduction To Flow

Intended for developers interested in getting started with Flow. At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.

Covers all the basics needed to get started with Flow.

Covers all the basic needed to get started with Flow and ReactJS.

@busypeoples
busypeoples / FlowReactTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For ReactJS Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@busypeoples
busypeoples / FlowTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For JavaScript Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is