How to use the @cycjimmy/awesome-js-funcs/designPattern/CreateInstance function in @cycjimmy/awesome-js-funcs

To help you get started, we’ve selected a few @cycjimmy/awesome-js-funcs 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 cycjimmy / h5-webpack-starter / app / share / promptMobile / PromptMobile.component.ins.js View on Github external
// constructor
import CreateInstance from '@cycjimmy/awesome-js-funcs/designPattern/CreateInstance';

import isMobile from '@cycjimmy/awesome-js-funcs/handheld/isMobile';

import promptMobile from './promptMobile.pug'
import _style from './promptMobile.scss'

// image
import QRCodeImg from '../../../static/images/QRCode.png';

const _createInstance = new CreateInstance();    // 构造函数实例

export default class PromptMobileComponentIns {
  constructor() {
    if (_createInstance()) {
      return _createInstance();
    }
    this.isMobile = false;
    this.wrapper = document.createElement('div');

    _createInstance(this);
  };

  load() {
    return new Promise((resolve, reject) => {
      if (isMobile()) {
        this.isMobile = true;
github cycjimmy / h5-webpack-starter / app / share / promptOrientation / PromptOrientation.component.ins.js View on Github external
import _style from './promptOrientation.scss';
import promptOrientation from './promptOrientation.pug';

import CreateInstance from '@cycjimmy/awesome-js-funcs/designPattern/CreateInstance';
import functionToPromise from '@cycjimmy/awesome-js-funcs/typeConversion/functionToPromise';

const _instance = new CreateInstance();

export default class {
  constructor() {
    if (_instance()) {
      return _instance();
    }

    this.wrapper = document.createElement('div');
    this.wrapper.classList.add(_style.wrapper);

    _instance(this);
  };

  load() {
    return functionToPromise(() => {
      this.wrapper.innerHTML = promptOrientation({
github cycjimmy / h5-webpack-starter / app / mainComponent / instanceComponent.js View on Github external
export default (Component) => {
  const _instance = new CreateInstance();

  return (param = {}) => {
    if (_instance()) {
      return _instance();
    }
    const component = new Component(param);
    _instance(component);
    return component;
  };
};