Skip to content

Instantly share code, notes, and snippets.

/* ui/unit/reducer.js */
import { onServerStateUpdate } from './interactions/serverStateUpdate';
export default createReducer(state, {
...onServerStateUpdate,
});
/* data/entities/reducer.js */
import { updateEntityOnEdit } from '../ui/unit/interactions/serverStateUpdate';
// Action creator: returns request action
const requestAction = postId => ({
type: 'POST_DELETE_REQUESTED',
postId,
});
// Action handler: reduces the state of the single leaf
const onRequest = {
POST_DELETE_REQUESTED:
(state, { postId }) =>
// Action creator: returns success action
const successAction = postId => ({
type: 'POST_DELETE_SUCCEEDED',
postId,
});
// Action handlers: passing array of the reducers for this action type
// to apply sequence of the changes to the state tree
const onSuccess = {
POST_DELETE_SUCCEEDED: [
/* @flow */
import { Record } from 'immutable';
interface $EnumInterface<T: Object> extends Record<T> {
items: Function;
fromValue: Function;
}
const createEnum = <T: Object>(items: T): $EnumInterface<T> => {
import createIcon from '.utils/createIcon';
import colors from './styles/colors';
const MyIcon = ({ color }) => (
<path fill={colors[color]} ... />
);
export default createIcon({
width: 16,
height: 16,
@alex35mil
alex35mil / 1-styles.css
Created April 18, 2017 06:41
CSS Modules + PostCSS + Webpack
:root {
--my-width: 400px;
}
:export {
myWidth: var(--my-width);
}
.myClass {
width: var(--my-width);
@alex35mil
alex35mil / ssl_smtp_example.go
Created September 22, 2017 13:51 — forked from chrisgillis/ssl_smtp_example.go
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
let all = Js.Promise.all;
let resolve = Js.Promise.resolve;
let reject = Js.Promise.reject;
let andThen =
(p: Js.Promise.t('a), fn: 'a => Js.Promise.t('b)): Js.Promise.t('b) =>
p->Js.Promise.then_(fn, _);
module Modifier = {
type t =
| Date(Js.Date.t)
| Range(Js.Date.t, Js.Date.t)
| Fn(Js.Date.t => bool);
let toJs =
(. x) =>
switch (x) {
| Date(date) => date
@alex35mil
alex35mil / App.re
Last active May 24, 2020 13:55
FCM
<TextField
icon=(module IconOk)
value
onChange=change
/>