1.0.3 • Published 3 years ago
@fkul/react-cf-ws-api v1.0.3
react-cf-ws-api
React WebSocket API for Crypto Facilities.
Getting started
yarn add @fkul/react-cf-ws-api
Interface
type CfWs = {
subscribePub(
feed: string,
products: string[],
callback: (data?: any) => void
): void
unsubscribePub(feed: string, products: string[]): void
getSubscriptionStatus(feed: string): string | null
}
subscribePub
- subscribes to a public feedunsubscribePub
- unsubscribes from a public feedupdateSubscription
- updates an existing subscriptiongetSubscriptionStatus
- gets the status of a subscription
Example
import { useCfWs } from '@fkul/react-cf-ws-api';
const Component = () => {
const ws = useCfWs()
// the callback function
const onFeedData = (data) => {}
// subscribe
ws.subscribePub("some_feed_name", ["som_product_id"], onFeedData)
return <></>
}
export default Component
Building
yarn build
Testing
yarn test