Last active
August 29, 2015 14:02
-
-
Save nin-jin/46d685328723d1c68a85 to your computer and use it in GitHub Desktop.
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 userData = $jin.atom({ pull: function( ){ | |
setTimeout( function( ){ | |
userData.put({ name: 'User', time: Date.now() }) | |
}, 1000 ) | |
}}) | |
userData | |
.then( function( val ){ | |
console.log( 'got1', val, Date.now() ) | |
} ) | |
userData | |
.then( function( val ){ | |
console.log( 'got2', val, Date.now() ) | |
} ) |
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 userDataDefer | |
var userData = function( ){ | |
if( !userDataDefer ){ | |
userDataDefer = Q.defer() | |
setTimeout( function( ){ | |
userDataDefer.resolve({ name: 'User', time: Date.now() }) | |
}, 1000 ) | |
} | |
return userDataDefer.promise | |
} | |
userData() | |
.then( function( val ){ | |
console.log( 'got1', val, Date.now() ) | |
} ) | |
userData() | |
.then( function( val ){ | |
console.log( 'got2', val, Date.now() ) | |
} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment