These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].
The most interesting being the Map literal
var map = im{"foo": "bar", "baz": "quux"};This compiles to the 2d array version of Immutable.Map.
| { | |
| "env": { | |
| "browser": true, | |
| "node": true, | |
| "es6": true | |
| }, | |
| "plugins": ["react"], | |
| "ecmaFeatures": { |
| import { Actions } from 'flummox'; | |
| export default class TodoActions extends Actions { | |
| constructor(db) { | |
| super(); | |
| this.db = db; | |
| } | |
| async create(model) { |
| (ns datascript-to-datomic-util | |
| (:require [datascript :as d])) | |
| ;;;; a utility to help with a datomic-datascript roundtrip process involving: | |
| ;;; 1. export some data from a datomic database and transact into a datascript instance. | |
| ;;; 2. perform one or more transactions against datascript. | |
| ;;; 3. transact the sum of all changes made against datascript back into datomic in a single tx | |
| ;;; this namespace contains two public functions: | |
| ;;; listen-for-changes: listen to datascript transactions and build up a record of changes |
| /** @jsx React.DOM */ | |
| var React = require('react'); | |
| var handlers = {}; | |
| var AsyncRoute = function(req) { | |
| return React.createClass({ | |
| getInitialState: function() { | |
| return { | |
| myComponent: handlers[req] |
These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].
The most interesting being the Map literal
var map = im{"foo": "bar", "baz": "quux"};This compiles to the 2d array version of Immutable.Map.
So, I just learned that gf exists. If your cursor is over a path in vim, and you type gf, it'll open that file/dir in a new buffer. You can also open in a new window/tab as detailed here.
In node, it'd be great if you could jump to a required file, huh? Trouble is, typically you don't put the .js on your require('./path/to/a/js/file'). No matter, vim has your back, just add set suffixesadd+=.js to your .vimrc and vim will try adding .js and see if it can find that file instead.
If you do a lot of spelunking in node_modules, it'd be great if you could jump to the directory of a required npm module too, right? A la, require('my-awesome-module'). Well, you can add set path+=$PWD/node_modules to your .vimrc too, and vim will add node_modules to the path, and jump to it's directory in node_modules (caveat: you must have opened vim from your project root for this too work).
For your cmd+c convenience:
| // This little dev server is basically a wrapped express server that 'hot loads' our javascript for super fancy and fast live reload in development | |
| var webpack = require('webpack'); | |
| var WebpackDevServer = require('webpack-dev-server'); | |
| var config = require('./webpack.config'); | |
| var port = process.env.HOT_LOAD_PORT || 3001; | |
| new WebpackDevServer(webpack(config), { | |
| publicPath: config.output.publicPath, | |
| hot: true |
| // Usage example: | |
| // | |
| // willTransitionTo(transition, params, query, callback) { | |
| // observeStore(DraftStore, s => s.isLoaded()).then(() => { | |
| // if (DraftStore.isMissingTitle()) { | |
| // transition.redirect('composeDraft', params); | |
| // } | |
| // }).finally(callback); | |
| // } |
In React's terminology, there are five core types that are important to distinguish:
React Elements
| 'use strict'; | |
| var React = require('react'); | |
| function createAsyncHandler(getHandlerAsync, displayName) { | |
| var Handler = null; | |
| return React.createClass({ | |
| displayName: displayName, |