Skip to content

Instantly share code, notes, and snippets.

@mweststrate
Created August 21, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mweststrate/439e6ea8770a843c317df1ccb7ed11fe to your computer and use it in GitHub Desktop.
Save mweststrate/439e6ea8770a843c317df1ccb7ed11fe to your computer and use it in GitHub Desktop.
const Document = observer(({ view, store }) => {
if (!store.isAuthenticated)
return <Login store={store} afterLogin={() => store.showDocument(view.documentId)} />
switch (view.document.state) {
case "pending":
return <h1>Loading document.. { view.documentId }</h1>
case "rejected":
return <Error error={view.document.reason} />
case "fulfilled":
return (
<div>
<button onClick={() => store.showOverview()}>Overview</button>
<h1>{ view.document.value.name }</h1>
<p> { view.document.value.text }</p>
</div>
)
}
})
const Error = ({ error }) => <h1>{"Error: " + error}</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment