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

spec out handleUndo (just a rough idea, and probably not actually the right solution) #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikermcneil
Copy link
Member

This is not a perfect solution. But for certain bits of generic logic, it might make sense:

await ƒ.createZohoRecord.undo('CustomModule99', {});

On the other hand, the biggest issue is that in many cases, the reversibility of an instruction really ends up being very specific to its use as an instruction, rather than something exclusive to its machine definition. For example:

var newStripeCustomerId = await ƒ.stripe.saveBillingInfo.with({
  emailAddress: 'mike@example.com'
});
await ƒ.stripe.saveBillingInfo.undo.with({
  emailAddress: 'mike@example.com'
});
^^ could _technically_ work, because we know this was a "create"

// But...
await ƒ.stripe.saveBillingInfo.with({
  emailAddress: 'mike@example.com',
  stripeCustomerId: 'cust_ba3f8a3'
});
await ƒ.stripe.saveBillingInfo.undo.with({
  emailAddress: 'mike@example.com',
  stripeCustomerId: 'cust_ba3f8a3'
});
^^ but THIS would have to throw an error, because it's impossible to know what the email was before we updated it to be "mike@example.com"


// In other words, we probably shouldn't define a `handleUndo` function for the `saveBillingInfo` machine.  We could, of course, but it would be a "sometimes" thing, which kinda sucks because it's confusing and inconsistent.

In practice, I think there's probably a better way to go about this in the form of some kind of affordance in userland... (That way at least argins and intermediate operations before the undo can be taken into account!)

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