dispatch

Can't use requestAction from Shell in Cakephp 2.5

可紊 提交于 2021-02-11 07:59:10
问题 As stated, when I use in a shell : $this->requestAction('/sites/zaz/option1'); The action doesn't get triggered. To test this, I tried : public function zaz($option1 = null) { CakeLog::write('acces', 'action triggered'); return 'got it !'; } And the action isn't done and there is no log written whatsoever. All my other logs do work. So I tried : $this->requestAction('/sites/actionwhichdoesntexist/option1'); And I got an error stating that the action doesn't exist. I really need to use

Can't use requestAction from Shell in Cakephp 2.5

≯℡__Kan透↙ 提交于 2021-02-11 07:58:11
问题 As stated, when I use in a shell : $this->requestAction('/sites/zaz/option1'); The action doesn't get triggered. To test this, I tried : public function zaz($option1 = null) { CakeLog::write('acces', 'action triggered'); return 'got it !'; } And the action isn't done and there is no log written whatsoever. All my other logs do work. So I tried : $this->requestAction('/sites/actionwhichdoesntexist/option1'); And I got an error stating that the action doesn't exist. I really need to use

Dynamic dispatch to derived class in C#

风格不统一 提交于 2021-02-07 12:33:17
问题 I'm trying to do the following: public abstract BaseClass { public virtual void ReceiveEvent(Event evt) { ProcessEvent(evt as dynamic); } private void ProcessEvent(object evt) { LogManager.Log(@"Received an event that is not being processed! Dispatch fallback"); } } public DerivedClass: BaseClass { private void ProcessEvent(SpecificEvent evt) { LogManager.Log("Processing Event"); } } SpecificEvents hit the fallback method instead of the one in the derived class. I use dynamic dispatch within

Swift DispatchGroup notify before task finish

让人想犯罪 __ 提交于 2021-02-07 07:41:24
问题 I'm using DispatchGroup to perform a task, but group.notify is being called before the task is completed. My code: let group = DispatchGroup() let queueImage = DispatchQueue(label: "com.image") let queueVideo = DispatchQueue(label: "com.video") queueImage.async(group: group) { sleep(2) print("image") } queueVideo.async(group: group) { sleep(3) print("video") } group.notify(queue: .main) { print("all finished.") } Logs: all finish. image video 回答1: Update: The question above actually runs

Swift write an async/await method with return value

╄→гoц情女王★ 提交于 2021-01-29 17:52:58
问题 I want to write an async-await method with a return value, but my code doesn't work. I also tried another way such as DispatchQueue.global DispatchGroup() and so on. Here is my code: func checkPassCode() -> Bool { var result = false let closure = { (_ flag:Bool) -> Void in result = flag } if var pin = self.keychain.get("pin") { let userPin = self.pin.joined(separator: "") let encryptedData = NSData(base64Encoded: pin, options: []) AsymmetricCryptoManager.sharedInstance

Dispatch action on the callback of socket.on()

故事扮演 提交于 2021-01-27 12:46:33
问题 So basically I got this socket, that is working correctly sending me 'new order' message. I'm using redux, and i want to dispatch an action, than a reducer would get it and my store would be updated. but this code doesn't do anything! socket.on('new order', (order) => { return (dispatch) => { dispatch(socketNewOrder(order)); } }); And here is my action, which is located at the same file: export const socketNewOrder = (order) => { return { type: 'SOCKET_NEW_ORDER', payload: order } } I also

Any way to dispatch a closure in laravel 5?

十年热恋 提交于 2021-01-27 07:13:57
问题 In laravel 4, I could push a closure onto the queue with queue::push(function...) , but this no longer works in laravel 5. Instead, it appears that I have to make a custom Job class for every function that I want to push onto the queue. Since the functions I want to be pushing are only a couple of lines long, and are only ever used in exactly one place, it really seems like a waste of time and space to be writing up a full class for every case. The best "solutions" I can currently think of,

Any way to dispatch a closure in laravel 5?

筅森魡賤 提交于 2021-01-27 07:11:15
问题 In laravel 4, I could push a closure onto the queue with queue::push(function...) , but this no longer works in laravel 5. Instead, it appears that I have to make a custom Job class for every function that I want to push onto the queue. Since the functions I want to be pushing are only a couple of lines long, and are only ever used in exactly one place, it really seems like a waste of time and space to be writing up a full class for every case. The best "solutions" I can currently think of,

how to dynamically call instance methods in typescript?

别等时光非礼了梦想. 提交于 2021-01-02 06:30:21
问题 I have an object and I want to dynamically call a method on it. Having typechecking would be nice but that maybe impossible. But I can't even get it to compile at all currently: const key: string = 'someMethod' const func = this[key] func(msgIn) gives me this error... Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'TixBot'. I tried some other type options without success. const key: any = cmd.func const func: any = this[key] Apart from @ts

Typescript: How to type the Dispatch in Redux

 ̄綄美尐妖づ 提交于 2020-12-30 05:30:54
问题 For example I want to remove the dispatch: any here: export const fetchAllAssets = () => (dispatch: any) => { dispatch(actionGetAllAssets); return fetchAll([getPrices(), getAvailableSupply()]).then((responses) => dispatch(actionSetAllAssets(formatAssets(responses)))); } There are 2 actions I dispatch above, actionsGetAllAssets and actionsSetAllassets . Here are the interfaces and actionCreators for both: // Interfaces interface IActions { GET_ALL_ASSETS: string; SET_ALL_ASSETS: string; GET