promise

Do not fail whole task even if one of promises rejected

旧巷老猫 提交于 2020-12-30 08:17:05
问题 In redux saga if we want to handle multiple promises, we can use all (which is equivalent of Promise.all ): yield all( users.map((user) => call(signUser, user)), ); function* signUser() { yield call(someApi); yield put(someSuccessAction); } The problem is , even if one of the promises (calls) fail, the whole task is cancelled. My goal is to keep the task alive , even if one of the promises failed. In pure JS I could handle it with Promise.allSettled , but whats the proper way to do it in

let promise wait a couple of seconds before return

荒凉一梦 提交于 2020-12-29 09:34:05
问题 I'm having a function returning a promise. In this function, we call a third party vender to send some push notification through their server. it looks like apiGetLoggedInUser.then( user => { return sendMessage(user.name); } ) However the thing is we decided to wait for 3 seconds before we really call this sendMessage function. However we'd prefer not to change sendMessage since it's provided. I'm wondering how to really do the "wait" part in this scenario since promise is used to remove

let promise wait a couple of seconds before return

≡放荡痞女 提交于 2020-12-29 09:32:18
问题 I'm having a function returning a promise. In this function, we call a third party vender to send some push notification through their server. it looks like apiGetLoggedInUser.then( user => { return sendMessage(user.name); } ) However the thing is we decided to wait for 3 seconds before we really call this sendMessage function. However we'd prefer not to change sendMessage since it's provided. I'm wondering how to really do the "wait" part in this scenario since promise is used to remove

let promise wait a couple of seconds before return

ぃ、小莉子 提交于 2020-12-29 09:32:08
问题 I'm having a function returning a promise. In this function, we call a third party vender to send some push notification through their server. it looks like apiGetLoggedInUser.then( user => { return sendMessage(user.name); } ) However the thing is we decided to wait for 3 seconds before we really call this sendMessage function. However we'd prefer not to change sendMessage since it's provided. I'm wondering how to really do the "wait" part in this scenario since promise is used to remove

Resolve promise into addEventListener

泄露秘密 提交于 2020-12-29 07:06:02
问题 I'm actually developping a text editor and just got stuck with an issue regarding the image upload and display method. What I'm trying to achieve On the click of a button in the toolbar, the app displays a pop-up for uploading a picture. The user can then drag'n drop the file or click and select the file through his file system. After the image is selected, I send it to the server through ajax which uploads it and store it in a folder. Once this is done, the server sends a response that the

Resolve promise into addEventListener

我是研究僧i 提交于 2020-12-29 07:04:30
问题 I'm actually developping a text editor and just got stuck with an issue regarding the image upload and display method. What I'm trying to achieve On the click of a button in the toolbar, the app displays a pop-up for uploading a picture. The user can then drag'n drop the file or click and select the file through his file system. After the image is selected, I send it to the server through ajax which uploads it and store it in a folder. Once this is done, the server sends a response that the

How to create async function using NAPI that return Promises

孤人 提交于 2020-12-25 19:02:40
问题 i am trying to create node module using NAPI .I have to create async function that returns promises. I don't want that testasynfunction will block NodeJS event loop. do_something_asynchronous is a synchronous function. napi_deferred do_something_synchronous(napi_env env,napi_deferred deferred){ printf("\n3) Function called"); //napi_deferred deferred; napi_value undefined; napi_status status; // Create a value with which to conclude the deferred. status = napi_get_undefined(env, &undefined);

Promise override causes then calls to error

折月煮酒 提交于 2020-12-13 07:56:18
问题 I have the following sample code. class test extends Promise { constructor(executor) { super(executor) } static getPromise() { return new test((res, rej) => { res(true) }) } } let t = test.getPromise() t.then(value => {console.log("Works")}, value => {console.log("Works")}) this works just fine, but if I were to put the same function directly into the super function, it throws an error. class test extends Promise { constructor(executor) { super((res, rej) => { res(true) }) } static getPromise

Rust/Webassembly/wasm-bindgen - getting values from `js_sys' Promise

拈花ヽ惹草 提交于 2020-12-13 07:47:48
问题 I'm playing with wasm-bindgen ( https://github.com/rustwasm/wasm-bindgen ), just out of curiosity. While playing with the Navigator ( web_sys crate) I stumbled upon this method: https://docs.rs/web-sys/0.3.36/web_sys/struct.MediaDevices.html#method.enumerate_devices it returns a Result<Promise, JsValue> ..now, I'm new to Rust, and my question is how can I fetch the value of the Promise ? How the Closure::wrap works? How to use it with then method to fetch the results? I wonder if someone

Rust/Webassembly/wasm-bindgen - getting values from `js_sys' Promise

孤街醉人 提交于 2020-12-13 07:47:40
问题 I'm playing with wasm-bindgen ( https://github.com/rustwasm/wasm-bindgen ), just out of curiosity. While playing with the Navigator ( web_sys crate) I stumbled upon this method: https://docs.rs/web-sys/0.3.36/web_sys/struct.MediaDevices.html#method.enumerate_devices it returns a Result<Promise, JsValue> ..now, I'm new to Rust, and my question is how can I fetch the value of the Promise ? How the Closure::wrap works? How to use it with then method to fetch the results? I wonder if someone