Closed westhomas closed 8 years ago
now you can just call this.getCartsSuccess
directly.
@goatslacker : How to call/refer another actions in the ActionClass ?
import alt from '../alt'
import { ajax } from 'jquery'
class MuhActions {
constructor() {
this.generateActions(
'getCartsSuccess',
'getCartsFail'
)
}
updateSomething() {
ajax()...
}
getCarts() {
ajax({ url: '/api/carts' })
.done((data) => {
this.getCartsSuccess([{'id': 1, 'created': (new Date()).toString(), 'userId': 123, 'firstName': 'Bob', 'lastName': 'Boberson'}])
this.updateSomething()
})
.fail((jqXhr) => {
this.getCartsFail("testing123")
})
}
}
export default alt.createActions(MuhActions)
this.updateSomething()
=> someStore.onUpdateSomething()
or thisAction.updateSomething
The following code works great for 0.17.9. But it seems 0.18 an upwards breaks. The calls to this.actions.* will break due to actions being undefined.
I'm assuming this could be related to the breaking changes in 0.18.0 but I'm not entirely sure why that would apply here.