How to use harmony-reflect - 10 common examples

To help you get started, we’ve selected a few harmony-reflect 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 provable-things / dapp-proof-of-identity / ui / react-wallet-ui / src / components / Web3.js View on Github external
let web3 = typeof(window.web3) !== 'undefined' ? new Web3js(window.web3.currentProvider) : new Web3js(new Web3js.providers.HttpProvider(constant.LOCAL_NODE));

// Reflect required due to metamask providing a proxy object
try {
    if (web3.isConnected() === true) {
        Reflect.set(web3, 'isRemote', false);
    }
    else {
        throw new Error('No local node connection available...');
    }
}
catch (e) {
    console.log(e.message);
    web3 = new Web3js(new Web3js.providers.HttpProvider(constant.REMOTE_NODE));
    Reflect.set(web3, 'isRemote', true);
}

// meta-mask race condition workaround
window.addEventListener('load', () => {
    console.log('Page loaded...')
    if (web3.isRemote && typeof window.web3 !== 'undefined') {
        console.log('Injecting inpage web3...');
        // only use provider and use local web3
        let web3 = new Web3js(window.web3.currentProvider);
        Reflect.set(web3, 'isRemote', false);
        Promise.promisifyAll(web3.eth);
        exports.default = web3;
    }
});

Promise.promisifyAll(web3.eth);
github provable-things / dapp-proof-of-identity / ui / react-wallet-ui / src / components / Web3.js View on Github external
import * as constant from './Constant';
import Promise from 'bluebird';
import Web3js from 'web3';
import Reflect from 'harmony-reflect';

let web3 = typeof(window.web3) !== 'undefined' ? new Web3js(window.web3.currentProvider) : new Web3js(new Web3js.providers.HttpProvider(constant.LOCAL_NODE));

// Reflect required due to metamask providing a proxy object
try {
    if (web3.isConnected() === true) {
        Reflect.set(web3, 'isRemote', false);
    }
    else {
        throw new Error('No local node connection available...');
    }
}
catch (e) {
    console.log(e.message);
    web3 = new Web3js(new Web3js.providers.HttpProvider(constant.REMOTE_NODE));
    Reflect.set(web3, 'isRemote', true);
}

// meta-mask race condition workaround
window.addEventListener('load', () => {
    console.log('Page loaded...')
    if (web3.isRemote && typeof window.web3 !== 'undefined') {
        console.log('Injecting inpage web3...');
github Aferz / flask / src / core / Configurator.js View on Github external
registerGlobalDecorators(confObject) {
    const decorators = Reflect.get(confObject, 'decorators') || []
    this.registerDecorators(GLOBAL_NAMESPACE_DECORATOR, decorators)
  }
github Aferz / flask / src / core / Configurator.js View on Github external
registerServices(confObject) {
    const services = Reflect.get(confObject, 'services') || {}

    for (let alias in services) {
      const service = Reflect.get(services[alias], 'service')
      const args = Reflect.get(services[alias], 'arguments') || []
      const tags = Reflect.get(services[alias], 'tags') || []
      const decorators = Reflect.get(services[alias], 'decorators') || []
      const listeners = Reflect.get(services[alias], 'listeners') || {}
      const isSingleton = Reflect.get(services[alias], 'singleton') || false

      this.container.addService(alias, service, args, isSingleton)

      this.registerTags(alias, tags, this.container.getConfigValue('serviceDelimiter'))
      this.registerListeners(alias, listeners)
      this.registerDecorators(alias, decorators)
    }
  }
github Aferz / flask / src / core / Configurator.js View on Github external
registerServices(confObject) {
    const services = Reflect.get(confObject, 'services') || {}

    for (let alias in services) {
      const service = Reflect.get(services[alias], 'service')
      const args = Reflect.get(services[alias], 'arguments') || []
      const tags = Reflect.get(services[alias], 'tags') || []
      const decorators = Reflect.get(services[alias], 'decorators') || []
      const listeners = Reflect.get(services[alias], 'listeners') || {}
      const isSingleton = Reflect.get(services[alias], 'singleton') || false

      this.container.addService(alias, service, args, isSingleton)

      this.registerTags(alias, tags, this.container.getConfigValue('serviceDelimiter'))
      this.registerListeners(alias, listeners)
      this.registerDecorators(alias, decorators)
    }
  }
github Aferz / flask / src / core / Configurator.js View on Github external
registerConfigValues(confObject) {
    const values = Reflect.get(confObject, 'config') || {}

    for (let key in values) {
      this.container.addConfigValue(key, values[key])
    }
  }
github Aferz / flask / src / core / DecoratorResolver.js View on Github external
find(alias) {
    return Reflect.get(this.decorators, alias) || []
  }
github Aferz / flask / src / core / Configurator.js View on Github external
registerServices(confObject) {
    const services = Reflect.get(confObject, 'services') || {}

    for (let alias in services) {
      const service = Reflect.get(services[alias], 'service')
      const args = Reflect.get(services[alias], 'arguments') || []
      const tags = Reflect.get(services[alias], 'tags') || []
      const decorators = Reflect.get(services[alias], 'decorators') || []
      const listeners = Reflect.get(services[alias], 'listeners') || {}
      const isSingleton = Reflect.get(services[alias], 'singleton') || false

      this.container.addService(alias, service, args, isSingleton)

      this.registerTags(alias, tags, this.container.getConfigValue('serviceDelimiter'))
      this.registerListeners(alias, listeners)
      this.registerDecorators(alias, decorators)
    }
  }
github Aferz / flask / src / util / config.js View on Github external
const registerServices = (services, flask) => {
  for (let alias in services) {
    const service = Reflect.get(services[alias], 'service')
    const args = Reflect.get(services[alias], 'arguments') || []
    const tags = Reflect.get(services[alias], 'tags') || []
    const decorators = Reflect.get(services[alias], 'decorators') || []
    const listeners = Reflect.get(services[alias], 'listeners') || {}
    const isSingleton = Reflect.get(services[alias], 'singleton') || false

    isSingleton === true
    ? flask.singleton(alias, service, args)
    : flask.service(alias, service, args)

    registerTags(alias, tags, flask)
    registerDecorators(alias, decorators, flask)
    registerServiceListeners(alias, listeners, flask)
  }
}
github Aferz / flask / src / core / Configurator.js View on Github external
registerGlobalListeners(confObject) {
    const listeners = Reflect.get(confObject, 'listeners') || {}
    this.registerListeners(GLOBAL_NAMESPACE_LISTENERS, listeners)
  }

harmony-reflect

ES5 shim for ES6 (ECMAScript 6) Reflect and Proxy objects

(Apache-2.0 OR MPL-1.1)
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis