Git Product home page Git Product logo

Comments (5)

amcdnl avatar amcdnl commented on May 30, 2024 1

Published and verified in prod it works! THANKSSSSS!

from ngrx-actions.

albyrock87 avatar albyrock87 commented on May 30, 2024

OMG you're right!!
I think that this is the only way to do it:

function Select(fn) {
  return function(target: any, name: string): void {
    const createSelect = function () {
      // "this" is the final object reference
      console.log('new creation - must be logged once', this);
      return store.select(fn);
    };

    const selectorFnName = '__' + name + '__selector';

    const getter = function () {
      // "this" is the final object reference
      return this[selectorFnName] || (this[selectorFnName] = createSelect.apply(this)); 
    };

    // Redefine property
    if (target[selectorFnName]) {
      throw new Error('You cannot use @Select decorator and a ' + selectorFnName + ' property.');
    }
    if (delete target[name]) {
      console.log('define property');
      Object.defineProperty(target, selectorFnName, {
        writable: true,
        enumerable: false,
        configurable: true
      });
      Object.defineProperty(target, name, {
        get: getter,
        enumerable: true,
        configurable: true
      });
    }
  };
}

class Foo {
  @Select()
  bar;
}

var f = new Foo();
f.bar;
f.bar;
f.bar;

from ngrx-actions.

amcdnl avatar amcdnl commented on May 30, 2024

CLEVER! I'll make this change and see if it fixes the issues in prod env.

from ngrx-actions.

albyrock87 avatar albyrock87 commented on May 30, 2024

Uh ok... I was writing a pull reqest. No problem.. :)

from ngrx-actions.

amcdnl avatar amcdnl commented on May 30, 2024

what's ur email, i'd like to add u to my slack channel.

from ngrx-actions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.