Skip to content

Instantly share code, notes, and snippets.

@awv-inf
awv-inf / renderer.js
Last active September 5, 2017 11:56
Translates JSX into plugin.addElement calls, manages lifecycle and updates, mimicking Reacts API.
import omit from 'lodash/omit'
import flatten from 'lodash/flattenDeep'
import isEqual from 'lodash/isEqual'
import Element from './element'
import shallowEqual from 'shallow-equal/objects'
import hash from 'string-hash'
let queue = Promise.resolve(),
currentId,
frames = {}
@awv-inf
awv-inf / webpack.config.babel.js
Created December 2, 2016 13:30
redux example config
import path from "path";
import webpack from "webpack";
module.exports = env => {
const devBabelPresets = env.dev ? [
["env", { modules: false, loose: true, "targets": { "chrome": 55 } }]
] : [];
const prodBabelPresets = env.prod ? [
@awv-inf
awv-inf / .js
Last active October 4, 2016 09:44
observe deep
// MANUALLY
// Create deep observer, pre-select tree
let observer = createObserverDeep(store, () => store.getState().tree)
// Use it to observe object 5 (Sketch)
let unsubscribe = observer(state => state.get("5"), (state, previous) => console.log(state, previous))
// Change vector x-coordinate in object 4 (Endpoint), deeply linked to object 5 (Sketch))
session.patch([ { op: 'replace', path: '/4/vector/0', value: 100 } ])