Created
March 11, 2015 22:20
-
-
Save liammclennan/50d58f366b99f38f5926 to your computer and use it in GitHub Desktop.
Euclid usage
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
euclid.start([{ | |
title: 'Home', | |
entry: function () { | |
return server.getDecks().then(function (decks) { | |
loginChanges(); | |
var data = {decks: decks}; | |
return [components.Home(data), data]; | |
}, function () { | |
return [components.NotAuthenticated(), {}]; | |
}); | |
}, | |
actions: { | |
importDemo: function () { | |
var props = this, | |
url = 'https://github.com/liammclennan/maths.wiki.git'; | |
return server.importGitWiki(url).then(function () { | |
euclid.navigate('Deck', {url: encodeURIComponent(btoa(url))}); | |
return props; | |
}); | |
} | |
} | |
}, | |
{ | |
title: 'Login', | |
entry: function () { | |
logoutChanges(); | |
var data = {}; | |
return [components.LoginPage(data), data]; | |
}, | |
actions: { | |
login: function (email) { | |
var props = this; | |
return server.login(email).then(function () { | |
props.message = "An login email has been sent to your email address " + email + '. Check your email and follow the login link.'; | |
return props; | |
}); | |
} | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
euclid.start
.title
doubles as the page route.entry
function.entry
function is expected to return an array containing [, ] or a promise containing the same.Actions
define the things that the page can do. When the user does something on that page (submit a form or whatever) the react component delegates to one of the actions. Each action mutates the page data (props) and returns the updated state.