我的徽标数改变后不能实时更新。dva中是如何进行ajax轮询的?
<a href="notifications" onClick={setRead}><Badge count={BadgeNumber}><Icon type='message' style={{ fontSize: 42, color: '#00d9ff' }} /></Badge> </a>
BadgeNumber就是徽标数了,我现在是通过mysql函数从后台传过来的。
models effect中获取BadgeNumber:
const Badge = yield call(notification.getBadgeNumber, { recipientId: id })
Dva
的model
中有个subscriptions
。在这里监听
pathname
,在符合条件的时候,setInterval(dispatch(your effect), interval_time)
;这种消息最好使用
websocket
处理。