frame-js / Frame

Frame is a flow based programming library for databases, APIs, utilities, objects, schemas and more!
MIT License
17 stars 2 forks source link

API Proposal for Iterables. This let's streaming API be used in `for ... of` syntaxes. #12

Open bugs181 opened 5 years ago

bugs181 commented 5 years ago

Example:

let users = Gun.from(“users”).iterate
for (let user of users) {
   // Do something with user
}
bugs181 commented 5 years ago

Since iterables use the flow mechanism, it would be possible to also write an iterateOn addition.

iterate Example:

let users = Gun.from(“users”).iterate // Assume [1, 2, 3]
for (let user of users) {
   // Do something with user
}

iterateOn Example:

let users = Gun.from(“users”).iterateOn // Assume default [1, 2, 3] and add: [4]
for (let user of users) { // First trigger would be [1, 2, 3]
   // Do something with user
}

users.push(4) // triggers above loop with [4]