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

Remove withParent #323

Merged
merged 1 commit into from
Jun 20, 2023
Merged

Remove withParent #323

merged 1 commit into from
Jun 20, 2023

Conversation

Pimm
Copy link
Collaborator

@Pimm Pimm commented Jun 20, 2023

This library relies heavily on the network, which makes it asynchronous throughout. Asynchronicity doesn't mix well with stateful operations such as withParent.

While this code will always work:

const payment = await mollieClient.customerPayments.withParent({ id: 'cst_pzhEvnttJ2' })
                                                   .create([]);

This code may be surprising:

mollieClient.customerPayments.withParent({ id: 'cst_pzhEvnttJ2' });
// […]
const payment = mollieClient.customerPayments.create([]);

If withParent is called after that first line executes but before the second one does, it will overwrite the customer. If the await keyword appears between those two lines, that withParent call could be anywhere.

The stateless variant does not have this issue:

const payment = await mollieClient.customerPayments.create({ customerId: 'cst_pzhEvnttJ2',});

This change is breaking. The next release will be 4.0.0. withParent was deprecated in 2018.

This library relies heavily on the network, which makes it asynchronous throughout. Asynchronicity doesn't mix well with stateful operations such as withParent. withParent was deprecated in 2018.
Copy link
Collaborator

@dsempel dsempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me 👍

@Pimm Pimm merged commit f8be354 into master Jun 20, 2023
@Pimm Pimm deleted the pimm/spring-cleaning branch June 20, 2023 15:10
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.

2 participants