Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.OmniStoreFlows = exports.omniContainer = void 0;

var _mobx = require("xmobx/mobx");

var _mobxReact = require("xmobx/mobx-react"); // import { types, addMiddleware } from 'xmobx/mobx-state-tree'
// https://github.com/mobxjs/mobx-react/blob/master/src/observer.js#L326


const isObserver = Target => Target.isMobXReactObserver === true;

const toObserver = Target => isObserver(Target) ? Target : (0, _mobxReact.observer)(Target); // tricky thing here is you have to pass in an app before rendering it
// const { children } = props
// const InjectedTarget = inject('store')(InjectedTarget)
// const Injector = inject(
//   stores => ({
//     // omnistore
//     store: stores.store,
//   })
// )
// const InjectedTarget = Injector(React.Children.only(children))


class OmniStoreFlows {
  // store: typeof OmniStoreType ={}
  static init() {
    return new OmniStoreFlows();
  }

  setStore(store) {
    this.store = store; // may not want this
    // this.subscribe()
    // if (typeof window === 'object') {
    //   window.omnistore = store
    //   window.endpoints = endpoints
    //   window.apis = apis
    // }
  }

  constructor(store) {
    // observable.ref
    (0, _mobx.extendShallowObservable)(this, OmniStoreFlows.types);
  } // https://github.com/mobxjs/mobx-state-tree/blob/master/API.md#onaction
  // subscribe() {
  //   addMiddleware(this.store, (call, next) => {
  //     if (call.name === 'toggleFilter') {
  //       console.dev(`Toggle Filter Called With ${call.args[0]} And ${call.args[1]}`)
  //       return next(call)
  //     }
  //     if (call.name === 'applySort') {
  //       console.dev(`Apply Sort Called With ${JSON.stringify(call.args[0])}`)
  //       return next(call)
  //     }
  //     return next(call)
  //   })
  // }


  inject(Target) {
    const View = toObserver(Target); // const omniInject = inject(injectionMapper)
    // const InjectedTarget = omniInject(Target)

    const InjectedTarget = (0, _mobxReact.inject)('store')(View); // @NOTE can add ANY props or injected child context attributes
    // there is nothing but routing & server side rendering JOBS above this component

    return InjectedTarget;
  }

}

exports.OmniStoreFlows = OmniStoreFlows;
OmniStoreFlows.types = {
  store: {} // router = oneRouter.observe()

};
const omniContainer = OmniStoreFlows.init();
exports.omniContainer = omniContainer;
var _default = omniContainer;
exports.default = _default;