Coder Social home page Coder Social logo

Comments (5)

angelnikolov avatar angelnikolov commented on June 25, 2024 1

Yes, it is.
https://github.com/angelnikolov/ngx-cacheable/blob/dc1c2cc90cbd09f9209a82632a161ce49fa12466/common/index.ts#L8

from ts-cacheable.

jmls avatar jmls commented on June 25, 2024

oh unless I supply my own DEFAULT_CACHE_RESOLVER ;) maybe that will work

from ts-cacheable.

jmls avatar jmls commented on June 25, 2024

no, it doesn't as decorators only work on the class definition, not instance.

however there is a dirty little hack .. if you add this line

parameters.push(this);

just under these lines (lines 79 of cacheable.decorator.ts)

  (propertyDescriptor.value as any) = function(..._parameters) {
    let parameters = JSON.parse(JSON.stringify(_parameters));
    parameters.push(this);

then you get the instance of the sub-class from which you can then grab whatever you need to make the cache comparison

I don't know if this breaks stuff - but it is a simple, non-obtrusive way of getting the sub class instance into the cache resolver

from ts-cacheable.

cyberbobjr avatar cyberbobjr commented on June 25, 2024

Hi,
Sorry for the necropost, but does this trick was implemented in the current version of Ngx-cacheable, because it might be usefull for my project :)

from ts-cacheable.

cyberbobjr avatar cyberbobjr commented on June 25, 2024

you're great ! many thanks for your job 😄

from ts-cacheable.

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.