Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
Update solutions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itaysabato authored Jun 13, 2018
1 parent 7e0a502 commit 960dda6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions use-cases/extras/solutions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ The purpose of this document is to explore possible hooks and/or APIs that may b

Suggestions will be listed and discussed in an arbitrary order and may contain overlaps in functionality as well as in the problems they intend to solve.

## Suggestion I - Async Functions Controller
## Suggestion I - Async Function Hooks
**Idea:** Provide hooks for prominent moments in an async function's lifecycle and allow values to be replaced by the hooks.

## Example
See these [TypeScript hook definitions](https://github.com/itaysabato/regrettable/blob/master/hooks/hook-types.ts).

This comment has been minimized.

Copy link
@MayaLekova

MayaLekova Jun 14, 2018

Is the Controller in the type definition the same as in Suggestion II?


More info [here](https://github.com/itaysabato/regrettable#api-by-example).

## Suggestion II - Async Functions Controller
**Idea:** Give the invoker of an async function (some) ability to control its execution in a backward compatible way.

### Example
Expand Down Expand Up @@ -58,7 +66,7 @@ const {

```

## Suggestion II - Promise Interceptors
## Suggestion III - Promise Interceptors
**Idea:** Provide new promise hooks that not only _inform_ of promise creations and resolutions but can also _affect_ the outcome.

[This reference implementation](https://gist.github.com/itaysabato/f78394793ae265c7895e862c2b2bd215) demonstrates a possible implementation of a "Bluebird-style" cancellation API on top of native promises via a promise _interception_ hooks API that I drafted therein.
Expand Down Expand Up @@ -97,13 +105,13 @@ async function finallySay(something) {
cancel(finallySay("Cancelled"))
```

## Suggestion III - Informative Promise Hooks + Async Functions Controller
## Suggestion IV - Informative Promise Hooks + Async Functions Controller
**Idea:** Combine the above two approaches such that async functions and generators are cancelled via `.return()` and relationships between promises are tracked via promise hooks.

### Details
**_TBD_**

## Suggestion IV - Benji's Context Idea
## Suggestion V - Benji's Context Idea
**Idea:** **_TBD_**

### Details
Expand Down

0 comments on commit 960dda6

Please sign in to comment.