1.4.0 • Published 6 months ago
@exodus/sync-time v1.4.0
@exodus/sync-time
This Exodus SDK feature provides a startOfHour timestamp via redux, which is synchronized with the Exodus server time.
Install
yarn add @exodus/sync-timeUsage
This feature is designed to be used together with @exodus/headless. See using the sdk.
import createExodus from '@exodus/headless'
import syncTime from '@exodus/sync-time'
const container = createExodus({ adapters, config, debug })
container.use(syncTime())Play with it
- Open the playground http://localhost:8008/features/time
- Run
new Date(selectors.time.startOfHour(store.getState()))in the Dev Tools Console.
API Side
See using the sdk for more details on how features plug into the SDK. Note that this feature currently doesn't provide a top level API.
UI Side
See using the sdk for more details on basic UI-side setup.
!IMPORTANT You probably do NOT want to use the
selectors.time.timeselector as its value will only be updated periodically.
import exodus from '~/ui/exodus'
import selectors from '~/ui/flux/selectors'
const MyComponent = () => {
const startOfHour = useSelector(selectors.time.startOfHour)
console.log('>>> startOfHour', startOfHour) // timestamp with millis
}