How to use the hyperactiv/mixins.Observable function in hyperactiv

To help you get started, we’ve selected a few hyperactiv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zgsrc / ibjs / index.js View on Github external
}
        else res.end();
    });
    
    return app;
}

////////////////////////////////////////////////////////////////////////////////////////////////
// Startup Environment
////////////////////////////////////////////////////////////////////////////////////////////////
const createContext = require("./runtime"),
      wellKnownSymbols = require("./lib/symbol").wellKnownSymbols,
      repl = require("repl"),
      { observe, computed, dispose } = require("hyperactiv"),
      { Observable, Computable } = require("hyperactiv/mixins"),
      ObservableObject = Computable(Observable(Object)),
      wss = require('hyperactiv/websocket/server').server;



async function environment(config) {
    config.hooks = config.hooks || { };
    if (config.hooks.init) await config.hooks.init(config);
    
    if (config.symbols) {
        Object.assign(wellKnownSymbols, config.symbols)
    }
    
    if (config.cache) {
        require("./lib/model/contract").cache = require('memoize-fs')({ cachePath: config.cache });
    }
github zgsrc / ibjs / lib / model / subscription.js View on Github external
const { Observable, Computable } = require("hyperactiv/mixins");

class Subscription extends Computable(Observable(Object)) {
    
    constructor(base, data) {
        super({ });
        
        if (base) {
            if (base.service) {
                Object.defineProperty(this, "contract", { value: base, enumerable: false });
                Object.defineProperty(this, "service", { value: base.service, enumerable: false });
            }
            else if (base.socket) {
                Object.defineProperty(this, "service", { value: base, enumerable: false });
            }
        }
        
        Object.defineProperty(this, "subscriptions", { value: [ ], enumerable: false });
    }
github zgsrc / ibjs / runtime / index.js View on Github external
require("sugar").extend()

const { observe, computed, dispose } = require("hyperactiv"),
      { Observable, Computable } = require("hyperactiv/mixins"),
      ObservableObject = Computable(Observable(Object));

const utility = {
    at: require('node-schedule').scheduleJob,
    get time() { return Date.create() },
    require,
    process,
    observe,
    computed,
    dispose,
    Observable,
    Computable,
    ObservableObject
}

let math = require("simple-statistics")
Object.assign(math, require("numeric"))
github zgsrc / ibjs / run / environment.js View on Github external
const { session, constants } = require("../index"),
      { processCommandLineArgs, preprocess } = require("./program"),
      { observe, computed, dispose } = require("hyperactiv"),
      { Observable, Computable } = require("hyperactiv/mixins"),
      wss = require('hyperactiv/websocket/server').server,
      ObservableObject = Computable(Observable(Object)),
      Context = require("./context"),
      http = require('http'),
      WebSocket = require('ws'),
      express = require('express'),
      bodyParser = require('body-parser'),
      util = require('util'),
      repl = require("repl");

function createApp(context, app) {
    app = app || express();
    
    app.use("/hyperactiv", express.static("node_modules/hyperactiv"));
    app.use(express.static(__dirname + '/html'));
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());

hyperactiv

Super small observable & reactive objects library.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis