Skip to content

Instantly share code, notes, and snippets.

View markmarijnissen's full-sized avatar

Mark Marijnissen markmarijnissen

View GitHub Profile
@markmarijnissen
markmarijnissen / readme.md
Last active August 29, 2015 14:04
Webpack notes

Config requirements

  • Require jade, coffee,less
  • cordova.js should be loaded externally
  • Copy file assets (png,jpg,ttf,etc) rather than hashing them.
  • Multiple, independant bundles: /src/[name]/main.js --> /dist/[name]/bundle.js

##Enhancements:

Copy static assets

@markmarijnissen
markmarijnissen / test.js
Created August 24, 2014 13:14
Convert Cordova-style callbacks to Nodejs-style callbacks
/**
* Copy-paste this in your console to test if function works as expected
**/
function toNodejsFn(cordovaFn,self){
return function(){
var args = Array.prototype.slice.call(arguments,0);
var callback = args.splice(args.length-1,1)[0];
args.push(function onSuccess(){
var args = Array.prototype.slice.call(arguments, 0);
args.unshift(null);
@markmarijnissen
markmarijnissen / data.md
Last active August 29, 2015 14:16 — forked from dtheodor/data.md

Problem:

  • There's a module that knows how to load (and re-load) data through an API, and stores it locally.
  • Multiple modules access the loaded data, and transform them into a different representation (each module does a different transform), also storing them locally
  • The transformed data is exposed to the view, with a 'loading' indication when the original data is (re)loaded and/or the transformation is in progress.

##API idea

Promises support:

  • on resolution callbacks, where the transform function can be attached.
  • a isResolved attribute, which is false when the promise has been started but not yet resolved.
@markmarijnissen
markmarijnissen / example.js
Created July 5, 2017 18:06
Placeholder function
// In your parent
import placeholderfunction from "./placeholderfunction";
class Parent extends Component {
// A placeholder function is a function that is not yet implemented
save = placeholderfunction();
render() {
<button onClick={this.save}>Save</button>
<Child save={this.save} />