3 ms·
Question: I couldn’t figure out how to export properties that were writable in JS. I describe the problem in Entity.js. Any pointers would be much appreciated!
by trzy 4y ago
Question: I couldn’t figure out how to export properties that were writable in JS. I describe the problem in Entity.js. Any pointers would be much appreciated! :)
- ladberg 4y agoUnfortunately I also can't figure that out... The autogenerated bindings from JS <-> ObjC/Swift are pretty opaque and if it doesn't handle your use case then there isn't much you can do without manually binding everything you need. I might recommend using a custom class with getters/setters that don't use the subscript operator. I think on the JS side you can run some code to override [] and point it to the correct functions but I've never tried it out so ymmv.
- trzy 4y agoWell, I feel less bad about myself for getting stuck there :D The semantics of how properties work in JS are so obnoxious. A read-only property can still be replaced entirely, which means e.g.: entity.position = [0,0,0]; Is ok but: entity.position[0] = 1; entity.position[1] = 1; entity.position[3] = 1; Fails (and ChatGPT occasionally tries to do the latter).