Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
comply with lint-trap
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Mar 1, 2015
1 parent 52d70ae commit 87e362a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 57 deletions.
4 changes: 2 additions & 2 deletions bin/browserify-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ function main(fileName) {
module.exports = main;

if (require.main === module) {
var fileName = process.argv[2];
main(fileName).pipe(process.stdout);
var file = process.argv[2];
main(file).pipe(process.stdout);
}
8 changes: 4 additions & 4 deletions examples/geometry/lib/drag-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ function handleDrag(ev, broadcast) {
y: ev.offsetY || ev.layerY
};

function onmove(ev) {
function onmove(ev2) {
var previous = current;

current = {
x: ev.offsetX || ev.layerX,
y: ev.offsetY || ev.layerY
x: ev2.offsetX || ev2.layerX,
y: ev2.offsetY || ev2.layerY
};

var delta = {
Expand All @@ -30,7 +30,7 @@ function handleDrag(ev, broadcast) {
broadcast(extend(data, delta));
}

function onup(ev) {
function onup(ev2) {
delegator.unlistenTo('mousemove');
delegator.removeGlobalEventListener('mousemove', onmove);
delegator.removeGlobalEventListener('mouseup', onup);
Expand Down
4 changes: 2 additions & 2 deletions examples/number-input/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function App() {
}

App.render = function render(state) {
function numberspanny(name, state) {
function numberspanny(name, numberInput) {
return h('span', [
name,
NumberInput.render(state)
NumberInput.render(numberInput)
]);
}

Expand Down
3 changes: 1 addition & 2 deletions examples/server-rendering/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function add(state, data) {

App.render = require('./render.js');

var initialState = JSONGlobals('state');
var app = App(initialState);
var app = App(JSONGlobals('state'));
var targetElem = document.body.firstChild;
var prevTree = virtualize(targetElem);

Expand Down
8 changes: 4 additions & 4 deletions examples/unidirectional/backbone/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var AppState = backbone.Model.extend({

var events = mercury.input(['add']);

var state = new AppState({
var appState = new AppState({
description: 'app state description',
events: events,
items: new Items([
Expand All @@ -40,12 +40,12 @@ var state = new AppState({
});

events.add(function add(data) {
state.get('items').add(data);
appState.get('items').add(data);
});

window.state = state;
window.state = appState;

mercury.app(document.body, toObserv(state), render);
mercury.app(document.body, toObserv(appState), render);

function render(state) {
return h('div', [
Expand Down
70 changes: 35 additions & 35 deletions examples/unidirectional/backbone/observ-backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,46 @@ function toObserv(model) {
listener(serialize(model));
});
};
}

// listen to a Backbone model
function listen(model, listener) {
model.on('change', listener);
// convert a Backbone model to JSON
function serialize(model) {
var data = model.toJSON();
Object.keys(data).forEach(function serializeRecur(key) {
var value = data[key];
// if any value can be serialized toJSON() then do it
if (value && value.toJSON) {
data[key] = data[key].toJSON();
}
});
return data;
}

model.values().forEach(function listenRecur(value) {
var isCollection = value && value._byId;
// listen to a Backbone model
function listen(model, listener) {
model.on('change', listener);

if (!isCollection) {
return;
}
model.values().forEach(function listenRecur(value) {
var isCollection = value && value._byId;

// for each collection listen to it
// console.log('listenCollection')
listenCollection(value, listener);
});
}
if (!isCollection) {
return;
}

// listen to a Backbone collection
function listenCollection(collection, listener) {
collection.forEach(function listenModel(model) {
listen(model, listener);
});
// for each collection listen to it
// console.log('listenCollection')
listenCollection(value, listener);
});
}

collection.on('add', function onAdd(model) {
listen(model, listener);
listener();
});
}
// listen to a Backbone collection
function listenCollection(collection, listener) {
collection.forEach(function listenModel(model) {
listen(model, listener);
});

// convert a Backbone model to JSON
function serialize(model) {
var data = model.toJSON();
Object.keys(data).forEach(function serializeRecur(key) {
var value = data[key];
// if any value can be serialized toJSON() then do it
if (value && value.toJSON) {
data[key] = data[key].toJSON();
}
});
return data;
}
collection.on('add', function onAdd(model) {
listen(model, listener);
listener();
});
}
16 changes: 8 additions & 8 deletions examples/unidirectional/immutable/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ var data = Immutable.fromJS({
events: events
});

var state = Cursor.from(data);
var appState = Cursor.from(data);

events.add(function add(data) {
state.update('items', function pushItem(items) {
return items.push(Immutable.fromJS(data));
events.add(function add(newItem) {
appState.update('items', function pushItem(items) {
return items.push(Immutable.fromJS(newItem));
});
});

Expand Down Expand Up @@ -64,11 +64,11 @@ function toObserv(cursor) {
return cursor.deref();
}

cursor._onChange = function onChange(data) {
cursor._rootData = data;
listener(data);
cursor._onChange = function onChange(newData) {
cursor._rootData = newData;
listener(newData);
};
};
}

mercury.app(document.body, toObserv(state), render);
mercury.app(document.body, toObserv(appState), render);

0 comments on commit 87e362a

Please sign in to comment.