btford/react-palm

Feat/Doc: Cancelling tasks, subscriptions

btford opened this issue · 0 comments

I gotta think about this a bit.

  • Subscriptions are sometimes a better model. But "subscriptions" aren't intuitive for discrete tasks.
  • Cancellation implies eagerness. Tasks are lazy. You can't cancel something that hasn't happened.
  • You want to get a cancellable object back after dispatching the task.
  • Task -> Execution (cancellable) -> Result
  • Most of the time, you want the execution to be transparent.
task = xhr "google.com"
execution <- do task

// one of:
status <- cancel execution
result <- execution

but also:

task = xhr "google.com"
result <- do task

Prefer an API that's monomorphic– we don't actually want to overload do task.