>
> `myObj.onevent()` invokes `onevent()` with `this === myObj`. Unless
> you want to deviate significantly from normal JS semantics, you would
> need to maintain a reference to `myObj` anyway.
>
(The spec I'm emulating actually states that `onevent()` is invoked with
the global context.)
No, storing a weak reference on the object itself won't work.
Maybe a map of Persistent, not associated with the MyObj instances,
but keyed on the MyObj instance? SetOnevent stores to that map; firing an event
involves a lookup; MyObj's destructor deletes from the map?
Thanks,
Zach
--
--
Hello,
I'm trying to implement this type of interface:
var myObj = new MyObj();
myObj.onevent = function () {
// might be a reference to myObj here
}
myObj.doSomethingAsync(); // causes `onevent` to fire; can be called more
than once
`onevent` (a C++ setter) currently stores the callback
On Fri, Sep 2, 2016 at 3:54 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> On Fri, Sep 2, 2016 at 5:42 AM, Zach Bjornson <zbbjorn...@gmail.com>
> wrote:
> > Hello,
> >
> > I'm trying to fix some code that creates a wrapped C++ object ("Canvas",
Not sure if you still need help with this, but ... expanding on what Ben
said:
Node Buffers are Uint8Arrays (ArrayBufferViews) in version 4.x and later
only.
Small node Buffers ([currently] <4096 bytes) use a shared buffer as a
backing store, which is why you see a greater byteLength. You
Hello,
I'm trying to fix some code that creates a wrapped C++ object ("Canvas",
emulating HTMLCanvasElement) with property accessors on the prototype.
Specifically, these assertions should work to reflect browsers'
HTMLCanvasElement API:
var c = new Canvas(...);
Some of this has been discussed before, but the API has changed a lot
recently and I'm lost a bit in the discussion.
In v8 4.2.77.20 (version in iojs 2.4.0) the following seems to work for
arrays *larger than 64 bytes:*
LocalUint8ClampedArray arr = args[0].AsUint8ClampedArray();
void