frame-js / frame Goto Github PK
View Code? Open in Web Editor NEWFrame is a flow based programming library for databases, APIs, utilities, objects, schemas and more!
License: MIT License
Frame is a flow based programming library for databases, APIs, utilities, objects, schemas and more!
License: MIT License
Add initializing state. Due to the way flows are queued, initBlueprint
may be called multiple times even though the blueprint is currently being initialized.
Example:
Called init for Message
Called init for Message
Called init for Message
socket.init config: { host: 'localhost', port: 8082 }
socket.init config: { host: 'localhost', port: 8082 }
socket.init config: { host: 'localhost', port: 8082 }
socket.init config: { host: 'localhost', port: 8082 }
socket.in: something
Code:
'use strict'
const Frame = require('Frame')
// Blueprints
const Message = Frame('Message')
const Console = Frame('Console')
const Socket = Frame('Socket')
// Setup websocket server
const socketConfig = {
host: 'localhost',
port: 8082,
}
const socket = Socket(socketConfig)
Message
.from(socket, 'event')
.to(Console)
Message
.from(socket, '!')
.to(Console)
function addAnother() {
Message
.from('something')
.to(socket, 'another event')
}
addAnother()
Array destructing allows multiple blueprints to be included with minimal amount of syntax.
const [Mesh, HAM] = Frame(['Mesh', 'HAM'])
And multi-line
const [
Movie,
Song,
HTML,
React,
] = Frame([
'Movie',
'Song',
'HTML',
'React',
])
Resources:
Singletons should also be allowed to be instances when it's fitting. Maybe perhaps determined by initializer. For example a Storage adapter may be a singleton for a specific connection/directory, but another singleton for a different directory. This essentially groups flows into singletons deterministically.
Enhancement for better TypeError support
If anyone has any suggestions for Creative Commons works of art that would be ideal for Gravatar usage, this issue is open to collaborate on that and other marketing materials.
Will need to look into why the init
function is not being used in the Schema correctly.
Setup:
const Console = Frame('Console')
Testing init
:
> Console.init = true
< true
> Console.to(function(){})
Error: Blueprint 'Console' could not initialize.
TypeError: undefined is not a function (near '...blueprint.init.call...')
Testing in
:
> Console.in = true
Error: Expecting "in" to be one of "function", got "boolean"
Example:
// Can be a function
Message.from = function(data, props, cb) {}
// Can be an arrow function
Message.from = (data, _, cb) => cb()
// Can be a Blueprint module
Message.from = Slack
// Can be a primitive value
Message.from = 'Something'
Allowing blueprints to export themselves as a single function decreases the friction of development.
Use case:
Blueprint = function(...) {
}
Internally:
if (typeof Blueprint === 'function')
Blueprint = { name: Blueprint.name, in: Blueprint }
Example:
describe: {
init: {
config: {
port: 'Listen Port'
},
},
},
Using descriptions via the describe syntax on a Blueprint object, hands off parameter destructuring over to Frame for validating proper inputs and types.
Proposal (subject to change; and likely will to be the most flexible but easy to discern):
Blueprint = {
...
describe: {
init: {
'Optional Message Format': 'The message format will transform messages of one type to another for blueprint intercompatibility.'
},
accepts: 'Any', // Something like IMDB: accepts: [Movie, Show, Actor]
in: {
'Message': 'Any',
},
out: {
'Message': 'Any',
},
},
}
Example:
let users = Gun.from(“users”).iterate
for (let user of users) {
// Do something with user
}
Overview Progress:
protect()
functionAdd additional ObjectModel types:
Example:
{
user: String, // Required
age: ObjectModel.Optional, // Optional
gravatar: [Image, Element], // oneOf
}
Added types would be:
Add blueprint.Frame.canCatch
so we can determine whether an appropriate error path is available. Otherwise throw
to main application. In addition, add .catch()
API for all potential errors without error propagation handlers.
Progress:
blueprint.Frame.canCatch
.catch()
API.or()
APIA value getter which resolves a Promise when last flow is complete. Great for one-off flows that aren't meant to be continuous.
Example:
let message = await Movie.from(IMDB).to(ShowTimes).value
console.log(message)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.