Comments (3)
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.
@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.
@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)
- semver plz HOT 1
- restore d/d HOT 6
- lazy example doesn't work? HOT 2
- .
- No "main" in package.json HOT 1
- Fix version and tag HOT 5
- Consider default 'cew' characteristics for lazy resolved properties HOT 2
- Consider 'deepLevel: true' option for autoBind HOT 1
- Make it override friendly
- Intelligent handling for async lazy properties
- Rename d.gs into d.getSet
- No Longer Available on NPM HOT 10
- How to properly uninstall [email protected] package HOT 4
- The # in ext-es5 breaks in Vite HOT 1
- Rename the package? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d.