Library that helps with server-to-client synchronization of data. Depends on React, plays well with Redux.
The contract:
- Decorate your React component, provide config where you specify how to get data and what to do with it (e.g. dispatch to app state)
- You can count on the data being available as the decorated component renders
The example should get you going - detailed API docs pending :).
Example
Component { let title body = thisprops return <div> <h2> title </h2> <div> body </div> </div> } const updateBlogPost = { } )BlogPost
Global Configuration
You can override some default settings and behavior by calling the dataProvidersConfig({...})
function.
Optional overridable settings:
responseHandler
- function that acceptsresponse
from user definedgetData()
function and processes it. Default implementation expects aResponse
object (but simply returnsresponse
otherwise), and tries to parse the body as JSON object.loadingComponent
- component to display when DataProvider is fetching dataerrorComponent
- component to display when DataProvider fails initial fetch or refetchfetchTimeout
- time in milliseconds after which a new fetch (user suppliedgetData
) is called. Default is 30smaxTimeoutRetries
- max number of retries of thegetData
call after timeout. Default is 5
Example