1.0.15 • Published 3 years ago
@atomintl/shared-logic-deposit v1.0.15
买币集合页 WEB/RN 公用逻辑
- 示例
下面示例为 otc 示例,其他比如兑换、fastbuy 都是继承于同一基类,所以使用方式都是统一的
import { OtcOrderHelper, OrderType, EventName, OrderCheckReturn } from "@atomintl/shared-logic-deposit"
const Demo: React.FC = () => {
// 实例化对象也可赋值给useRef
const OtcHelper = new OtcOrderHelper(useLazyFetch)
// 用监听方式,监听数据变化,不同的EventName对应不同的业务
OtcHelper.subscribe<OrderCheckReturn>(EventName.OrderCheck, val => {
console.log(val)
})
OtcHelper.subscribe(EventName.OrderCheck1, val => {
console.log(val)
})
useEffect(() => {
OtcHelper.handleOrderCheck(OrderType.Sell)
}, [])
useEffect(() => {
// 也可以直接调用具体的方法获取数据
OtcHelper.handleOrderCheck(OrderType.Buy).then(
res => console.log(res) // 业务数据
)
}, [])
}