Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class('DataStore.Async', {
- trait : JooseX.CPS,
- continued : {
- methods : {
- log : function () {
- var resultFromLog = // somehow get the response from logging operation
- this.CONTINUE(resultFromLog)
- return whatever
- },
- save : function (data) {
- this.log().then(function (resultFromLog) {
- var CONT = this.CONT
- require('fs').saveFile('filename.txt', data, function (err, written) {
- if (err) {
- CONT.THROW(err)
- return
- }
- CONT.CONTINUE(written)
- })
- }).now()
- }
- }
- }
- })
- var store = new DataStore.Async
- store.save('some data').then(function (written) {
- // do smth
- }).CATCH(function (exception) {
- // do smth
- }).FINALLY(function () {
- // do smth
- }).now()
Add Comment
Please, Sign In to add comment