eventual-data
v1.1.0
Published
## POC trying out taggedSum from daggy
Downloads
1
Readme
eventual-data
POC trying out taggedSum from daggy
import React from 'react'
import ReactServer from 'react-dom/server'
import eventual, { Eventual } from './src/index'
export default function EventualData ( { data, children } ) {
return (
<Eventual
data={ data }
onLoading={ () => <span>Loading...</span> }
onError={ errors => <span>{ errors }</span> }
onSuccess={ data => children(data) }
/>
)
}
// const items = eventual.initial
console.log(ReactServer.renderToString(
<EventualData data={ eventual.initial }>
{ data => <span>{ data }</span> }
</EventualData>
))
// const items = eventual.loading
console.log(ReactServer.renderToString(
<EventualData data={ eventual.loading }>
{ data => <span>{ data }</span> }
</EventualData>
))
// const items = eventual.error(e)
console.log(ReactServer.renderToString(
<EventualData data={ eventual.error('Error!') }>
{ data => <span>{ data }</span> }
</EventualData>
))
// const items = eventual.success([])
console.log(ReactServer.renderToString(
<EventualData data={ eventual.success([ 1, 2, 3, 4, 5, 6 ]) }>
{ data => <span>{ JSON.stringify(data) }</span> }
</EventualData>
))