This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'AAAABBHHJOPPPP' | |
| .replace(/(\w)\1+/g, (match) => match[0] + (match.length)); | |
| // => "A4B2H2JOP4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // demo | |
| var _requestsCount = 6 | |
| const fetchF = url => { | |
| // _requestsCount-- | |
| console.log('fake request %d', _requestsCount) | |
| if (_requestsCount--) return Promise.reject(new Error('ololo')) | |
| return Promise.resolve('data') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const setEntities = (entityType, entities) => ({ | |
| type: 'SET_ENTITIES', | |
| payload: { entities }, | |
| meta: { entityType } | |
| }) | |
| export const removeEntities = (entityType, ids) => ({ | |
| type: 'REMOVE_ENTITIES', | |
| meta: { ids, entityType } | |
| }) | |
| export const setEntity = (entityType, entity) => ({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "react-apollo-starter-kit", | |
| "private": true, | |
| "description": "Scaphold.io's Starter Kit React and Apollo", | |
| "repository": "scaphold-io/react-apollo-starter-kit", | |
| "version": "0.1.0", | |
| "scripts": { | |
| "start": "babel-node ./src/server.js", | |
| "start-prod": "node ./lib/server.js", | |
| "build": "cp src/index.html lib/ && babel src --out-dir lib --sourceRoot src", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import WelcomeEmailMailer from './WelcomeEmailMailer' | |
| import SlackNotifier from './SlackNotifier' | |
| class NewRegistrationService { | |
| initialize (params) { | |
| this.user = params.user // Mongooose model: User | |
| this.organization = params.organization // Mongooose model: Organisation | |
| } | |
| perform () { | |
| return this.organizationCreate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function runSerial (tasks) { | |
| var result = Promise.resolve() | |
| tasks.forEach(task => { | |
| result = result.then(() => task()) | |
| }) | |
| return result | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var prop = (prop) => (obj) => obj[prop] | |
| var html = (selector) => (data) => $(selector).html(data) | |
| var render = (template) => (json) => Template.render(template, json) | |
| var comments = (params) => fetch('/comments', params).then(JSON.parse).then(prop('data')).then(render('commentsList')) | |
| var renderComments = (params) => comments(params).then(html('.comments')) | |
| renderComments({ user: 1 }).catch(err => console.error(err)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import Firebase from 'firebase' | |
| import ReactFireMixin from 'reactfire' | |
| import reactMixin from 'react-mixin' | |
| import LinkedStateMixin from 'react-addons-linked-state-mixin' | |
| const ref = new Firebase('https://<APP NAME>.firebaseio.com/') | |
| class Messages extends Component { | |
| constructor (props, context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import Firebase from 'firebase' | |
| import ReactFireMixin from 'reactfire' | |
| import reactMixin from 'react-mixin' | |
| const ref = new Firebase('https://<APPNAME>.firebaseio.com/users') | |
| class UsersList extends Component { | |
| constructor (props, context) { | |
| super(props, context) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import m from 'mithril' | |
| // Function for compose header and footer into layout | |
| function mixinLayout (layout, header, footer, body) { | |
| return layout(header, footer, body) | |
| } | |
| // Layout component | |
| function layout (header, footer, body) { |