Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we should not modify the Promise object #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

guiyep
Copy link

@guiyep guiyep commented Mar 6, 2019

when modifying the Promise object we make the JS engine to act strange since it is not a native promise.

For instance: Promise.all(immu([Promise.Resolve(), Promise.resolve()])) throws an exception. Since immu will modify the Promises and wrap it inside an immu object when it shouldn't.

this is a very common scenario when we get data from a redux strore and we map to get only the id and do a fetchP with it. as a result:

const test = async() => {
const immuArr = immue ([1,2,3]);
const mapToPromise = immuArr.map((id) => fetchP(id));
await Promise.all(mapToPromise) // this will throw: Method Promise.prototype.then called on incompatible receiver [object Promise]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant