Skip to content

Implement iterable context #6

@fabiancook

Description

@fabiancook

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions