Giter VIP home page Giter VIP logo

Comments (3)

medikoo avatar medikoo commented on June 12, 2024

I understand confusion, still lazy should not be understood as a getter, it's about lazy initialization of a variable and it also doesn't make sense as an initialization of some getter configuration

Lazy initialization, means that on first access, given value is initialized via provided function, then it's defined directly on an instance, and for any further access it's just accessed directly (no getters involved).

Also initial descriptor that is created with d(fn) is important, as it's characteristics would be used for variable definition on an instance. If we would ask to do it via d.gs then there would be a collision, as we wouldn't be able to control setting for writable characteristics (it doesn't apply to getters)

from d.

mjackson avatar mjackson commented on June 12, 2024

@medikoo Right on. Thanks for the explanation.

I think for me I'll just need to use several calls to Object.defineProperties: one using lazy and the other without.

from d.

medikoo avatar medikoo commented on June 12, 2024

@mjackson I think the most convenient way to to define both type of properties is as follows

Object.defineProperties(Object.assign({
  regularOne: d(....),
  regularTwo: d(...)
}, lazy({
  lazyOne: d(function () { ... }),
  lazyTwo: d(function () { ... })
}));

And I understand your point, initially I wanted to make lazy so it just return descriptor, but lazy needs to know the name of the property, that's the reason it's designed to work only with name/descriptor map.

from d.

Related Issues (16)

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.