Last active
July 26, 2016 00:18
-
-
Save PeterAronZentai/1551051a15f3d3e23e006337d5feec91 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
export class LogViewer extends React.Component<any, any> { | |
// some parts are omitted for brevity, like store subscription, or the actions | |
public defaultPresenter = ({message}) => <div>{message}</div> | |
public render() { return ( | |
<ul> | |
<li> | |
{logStore.items.map( m => { | |
const P = m.presenter || this.defaultPresenter | |
return <P key={m.id} {...m} /> | |
})} | |
</li> | |
</ul> | |
)} | |
} | |
//log simple string | |
log("simple text") //wraps log({message:"simple text"}) | |
//log some static markup | |
const walnutLogger = ({title, size}) => <div><b>{title}</b><i>{size}</i></div> | |
log({title:"walnut cake", | |
size:20, | |
presenter: walnutLogger | |
}) | |
//log something that you can update (like a progressbar) | |
const walnutLogger = ({title, size}) => <div><b>{title}</b><i>{size}</i></div> | |
const walnutLog = {title:"walnut cake", size:20, presenter: walnutLogger } | |
log(walnutLog) | |
while(theres_more_todo) { | |
const { theres_more_todo } = await asyncProcessOfYours() | |
logStore.dispatchTo(walnutLog, { progress: newProgressValue }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment