Below is a quick start guide to developing node.js on OSX. These tools and settings will give you just about everything you would need on a clean install of OSX 10.10.X to get setup and coding.
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
ref: https://stackoverflow.com/questions/63209420/react-global-state-no-context-or-redux | |
I have been using a similar approach and I really like it. I actually can't believe more people don't talk about this approach. I wrote a custom hook here React Superstore. It gives you the freedom to dispatch from anywhere in the app and shallow compares to avoid unwanted re-renders. I don't see any performance issues as long as you can avoid the unwanted re-renders. | |
In all it is a simple concept. You basically create a function to store your state and return 2 functions. One will be a function to set the stored state and one will be a hook to be used in the react component. In the hook you grab the setState function of react on initial render with a createEffect and store it in an array. You can then use this setState function to re render your component. So when you call the dispatch function you can just loop through these setState functions and call them. | |
Simple example: | |
import { useState, useEffect } from 'react |
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
'use strict'; | |
var m = require('mithril'); | |
var t = require('client/utils/translate'); | |
var vagueTime = require('vague-time'); | |
var l16n = require('client/utils/l16n'); | |
function assignValue(obj, objAttr) { | |
return function (event) { |
npm run scripts to handle the following:
- LESS for CSS pre-processor
- browserify for npm dependencies
- watchify for fast incremental bundling
- LiveReload browser refresh on bundle change
- LiveReload CSS injection on
*.less
change - budo to serve port 9966 and bring together some of the above tasks
- babelify for ES6 -> ES5
- errorify to show syntax errors in the browser during development
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
Widget = { | |
controller: function () { | |
this.css = Widget.stylesheet().classes | |
}, | |
view: function (ctrl) { | |
return m('.widget', [ | |
m('h3', { class: ctrl.css.head }), | |
m('div', { class: ctrl.css.body }) | |
]) | |
}, |
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
'use strict'; | |
var m = require('mithril'); | |
var extend = require('lodash').extend; | |
var setFocus = require('../util/viewhelper').setFocus; | |
var keymage = require('keymage'); | |
function noop(){} | |
function addClass(el, className) { |
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
// Mithril utilities | |
// Multi allows you to execute multiple functions as one. | |
// Especially useful when you want to bind several event handlers | |
// or run several config functions, for example binding a DOM plugin | |
// & assigning routing to a link. | |
// | |
// m( 'a.select2', { | |
// config : multi( m.route, select2plugin ) | |
// }, [] ); |
Just saw Douglas Crockfords talk at Craft Conference
http://www.ustream.tv/recorded/46640057
Just tried it and must say, it has a certain beauty in it.
No tangeling with prototypes and this/that fuckup.
var Animal = function(name, legs) {
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 fs = require('fs'); | |
var lame = require('lame'); | |
var Speaker = require('speaker'); | |
fs.createReadStream(process.argv[2]) | |
.pipe(new lame.Decoder()) | |
.on('format', function (format) { | |
this.pipe(new Speaker(format)); | |
}); |
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
# in config/env.yml | |
defaults: &defaults | |
ENV_YAML: true | |
development: | |
<<: *defaults | |
test: | |
<<: *defaults |
NewerOlder