To define a factory, service, controller or a directive, use the following format:
exports.inject = function(app) {
app.factory('MyFactory', exports.factory);
return exports.factory;
}
<!doctype html> | |
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ --> | |
<html> | |
<head> | |
<title>iOS 8 web app</title> | |
<!-- CONFIGURATION --> |
This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.
I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.
Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.
var path = require('path'); | |
/** | |
* CSS transform dependencies | |
*/ | |
var autoprefixer = require('autoprefixer-core'); | |
var calc = require('rework-calc'); | |
var color = require('rework-color-function'); | |
var conformance = require('rework-suit-conformance'); |
The MIT License (MIT) | |
Copyright (c) 2014 Tomas Kafka | |
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 | |
furnished to do so, subject to the following conditions: |
app.use(function(req, res, next) { | |
const router = Router.create({ | |
routes, | |
location: req.path | |
}); | |
router.run(function(Handler, state) { | |
router.transitionTo = function() { | |
const redirectUrl = router.makeHref.apply(router, arguments); | |
return Promise.reject({ reason: 'redirect', redirectUrl }); |
#Translating Marty to Redux
Some people have asked how I've translated a Marty app to Redux. Once you get your head around how Redux works I found concepts in Marty translated easily. Below is side-by-side comparison of the two libraries to help you along the way.
Also if you're looking for some devtools, check out redux-devtools.
##Constants
Marty
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
// Now your action creators can pull utilities our of their thunk api! | |
export function fetchUser(id) { | |
return ({api, dispatch}) => | |
api.fetch(`users/${id}`).then(resp => | |
dispatch({action: FETCH_USER, user: resp.body.data})); | |
} |