feat: raise get updater error

This commit is contained in:
EnixCoda 2019-03-04 10:47:17 +08:00
parent c3cf54f0b0
commit b7b0ca346a
No known key found for this signature in database
GPG key ID: 6825847C88AA329A

View file

@ -1,6 +1,5 @@
import * as React from 'react'
type x = [] extends any[] ? [] : any[]
import { raiseError } from 'analytics'
export type Method<Args = any[]> = (
...args: Args extends any[] ? Args : any[]
@ -82,8 +81,12 @@ function link<P, S>(instance: React.Component<P, S>, sources: Sources<P, S>): Wr
const dispatchState: DispatchState<P, S> = (updater, callback) => {
instance.setState(updater, callback)
}
const prepareState: PreDispatch<P, S> = updater => {
updater(instance.state, instance.props)
const prepareState: PreDispatch<P, S> = async updater => {
try {
await updater(instance.state, instance.props)
} catch (error) {
raiseError(error)
}
}
const dispatch: Dispatch<P, S> = {
call: dispatchCall,