Created
April 2, 2015 01:35
-
-
Save meric/a77f6633e023310be114 to your computer and use it in GitHub Desktop.
immstruct building pattern
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
// Content.js | |
Content.construct = function(statics, cursor, {country}) { | |
cursor = cursor.update(() => Immutable.fromJS({ | |
country: (country || ""), | |
url: statics.routePath, | |
})) | |
return new Promise((resolve, reject) => | |
setTimeout(() => resolve("Hello World"), 500)) | |
.then((value) => cursor.cursor('world').update(() => value)) | |
} | |
// ProfilePageList.js | |
ProfilePageList.construct = function(statics, cursor) { | |
cursor = cursor.update(() => Immutable.fromJS({ | |
crumbs: [ | |
{text: "Home", url: "/"}, | |
{text: "About", url: "/?1"} | |
], | |
title: "My Website" | |
})) | |
return Content.construct(statics, cursor.cursor('contentState'), | |
{country: "Australia"}) | |
} | |
// main | |
ProfilePageList.construct({ | |
routeParams: parameters, | |
routePath: window.location.pathname | |
}, structure.cursor()) | |
.then(() => { | |
var cursor = structure.cursor(); | |
document.title = cursor.cursor('title').deref(); | |
}) | |
.catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment