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

Implement iterable context #6

Open
fabiancook opened this issue Sep 11, 2019 · 2 comments
Open

Implement iterable context #6

fabiancook opened this issue Sep 11, 2019 · 2 comments
Assignees

Comments

@fabiancook
Copy link
Member

fabiancook commented Sep 11, 2019

Now that we have some fundamentals it would be good to clean up how we do things.

Implement an iterable context, this will hold operations, operations can be async or sync, it is up to the sync implementation to limit to only sync operations

An all operations will be weakly held against a single iterable

Operations must be invoked in order of creation

An iterable context can be marked as a tuple of n size

An iterable context can be marked as pure, this means all operations must be pure, given a value in, the exact same value out.

A pure context can be given factory producing a weak map or any other object with a get and set function.

The weak map type will be WeakMap<Operation, WeakMap<T, R>>, the object implementing get and set would follow this same signature. A get and set function allows for a shallow equals implementation.

In an async context the get and set functions may return a promise

The context should provide a clear function which invokes the map factory and resets the state (this will be useful for view)

When a context is pure and there is a record for the value and operation, the stored value will be used.

A context can be observed directly using Symbol.asyncIterator, each iteration will occur after each operation, the operations iterable will be returned from the iterator

A context can be given an existing state and operation to perform and move forward to that operation

The context will provide a property operations with the type WeakMap<Operation, Operation>
The context will provide a property initialOperation which will be the first operation, and finalOperation being the last
The operations map will be a linked list of operations, with the key as the current operation, and the child being the next, if the operations map doesn't have a key with an operation, it will be equal to finalOperation

An operation can have a return type of:

  • void
  • Iterable<T> where T is the value of the next iterable

Any terminating operations must be excluded from the context, for example toArray, drain, reduce, some, and every

@fabiancook fabiancook self-assigned this Sep 11, 2019
@fabiancook
Copy link
Member Author

A context must also be chain able, allowing a weak clone of the state, meaning we could probably do with a iterable of all the available operations, the final operation of the previous context will be the first operation of the next

A context could also be swapped into a pure context and swapped back if needed, providing a way to retain values for only a part of the chain

@fabiancook
Copy link
Member Author

It would be great to have a two step operation cycle, one for sync resolved operations, allowing to skip a single promise on each cycle, and then an async operation queue that will be hit when there are no more sync retrieved operations found

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

No branches or pull requests

1 participant