Last active
December 17, 2015 14:49
-
-
Save teddyzeenny/5626864 to your computer and use it in GitHub Desktop.
Backburner example: sync and render
This file contains 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 person, backburner = new Backburner(['sync', 'render']); | |
person = { | |
firstName: null, | |
lastName: null, | |
fullName: null, | |
twitter: null | |
}; | |
function set(prop, val) { | |
person[prop] = val; | |
backburner.deferOnce('sync', updateName); | |
backburner.deferOnce('render', redraw); | |
} | |
function updateName() { | |
person.fullName = person.firstName + ' ' + person.lastName; | |
} | |
function redraw() { | |
$('#person').text(person.fullName + ' - ' + person.twitter); | |
} | |
backburner.run(function() { | |
set('firstName', 'Erik'); | |
set('lastName', 'Bryn'); | |
set('twitter', '@ebryn'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment