Cool! The getImage example seems a tricky one. I'd probably implement that as an LRU cache so as not to presume images are held as references (imagine if the consumer of getImage places the gen'd images in <img src> as data URIs). More examples of potential usage may be useful.
-
-
-
This is why we worked to provide a more detailed explainer in the proposal README as well: https://github.com/tc39/proposal-weakrefs#readme … with
@littledan,@andywingo,@mhofman,@_gsathya, and yours truly The goal of the V8 feature explainer is to give a relatively succinct explanation.
Kraj razgovora
Novi razgovor -
-
-
When is this shipping in Chrome?
-
Stay tuned
(We have an implementation behind a flag.)
Kraj razgovora
Novi razgovor -
-
-
It doesn't seem to include a link to the proposal? I found it, but it should probably be included (and the status explained) so it doesn't look like a V8-only feature.
-
Nothing on http://v8.dev/features is V8-only feature. These are all standardized language features that V8 happens to ship (or in this case, implements behind a flag). There's already a link to the proposal in the article too.
- Još 1 odgovor
Novi razgovor -
-
-
Great post. In one of the notes, it is mentioned that the check `The ref !== undefined` is required. Did you actually mean both the checks `ref !== undefined && ref.deref() === undefined`? Since when a same name WeakRef is added both ref and ref.deref() will be defined.
-
Thanks! Updated the post
Kraj razgovora
Novi razgovor -
-
-
"Note: The finalization callback does not run immediately after garbage-collecting the image object. It either runs at some point in the future, or not at all — the spec doesn’t guarantee that it runs!" Why no guarantee?
-
It can provide side-channel attacks, and not all JS engines even have a GC in the first place.
- Još 1 odgovor
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.
Weak references and finalizers are (finally) coming to JavaScript!