-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.observe is obsolete with ES6. Try to find a solution with Proxy #3
Comments
Found that https://github.com/anywhichway/proxy-observe , but seem too heavy |
Thanks franckOL. We actually did see that this was deprecated and started experimenting with alternatives. Will report on our findings and hopefully provide a patch soon. For now, the ideal is to stick with the current Node LTS: 4.X which still supports Object.observe(). |
Hi, |
Sorry about that Franck, we missed the PR. This is really simple and great. I just accepted the PR, thanks a lot! |
Reopening as the new Node LTS is now 6 we'll be looking into this. |
Running the latest commit in master as of today. Still seeing the Running Node v6.10.0 over nvm |
Hi Guys ! Any solution to this problem ? I am going through chapter 7 of webofthings, and I am stuck because of this Object.observe problem when i try to execute the wot.js |
Hi guys, we have tested a number of solutions but haven't found a totally nice and simple one yet, we are still working on it but meanwhile I would stick to Node 4.X which supports Object.observe(). (you can install several version of node with NVM) |
Any update on this? |
Maybe we should work on some suggestions in the community to get them
started. The following may be a useful tutorial to get started.
https://www.bitovi.com/blog/long-live-es6-proxies
…On Sat, Jul 1, 2017 at 3:12 PM, logivity ***@***.***> wrote:
Any update on this?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACxalq47R2T3BTiH2RWKw5cQDOMlLpW7ks5sJfFVgaJpZM4Je5gQ>
.
|
Thanks for the ping and sorry for being so incredibly slow on that one. We had a fix (see PR) but there were a few weird behaviours. I'll get back to it asap but feel free to help. I'll start with a look at the link thanks for that. |
Hello, @domguinard, i see some evolution on W3C draft on WOT specification, also what is your advice . may be we can use ==> https://github.com/thingweb/node-wot ? |
@domguinard We had some previous discussion about the use of ES6 proxies. Another alternative would be the use of event emitters of which I am attempting to become more familiar. Any thoughts on this approach? |
Hi all, very new to this dev stuff. so dont mind my silly question. Just tried it in straight Chrome with out ind Browser wrapper. still the same. so it not the Ind Browser part that is an issue. and i cannot update the Browser on the Device. (Lollipop) Any ideas ? |
Hi all, thank you very much for the ideas exposed here. I personally have tries to implement the examples of chapter 7 using nest.js as a server. During the implementation, we also found the deprecated method To overcome this problem, I created a proxy variable to watch for changes in the object. Inside the proxy, I created an event emitter to send an event to the socket connection to perform the send operation to the WebSocket client: const myEvent = new EventEmitter();
const proxyResource = new Proxy(resourcesJson, {
get: function(target, prop) {
console.log({ type: 'get', target, prop });
myEvent.emit('ws-wot');
return Reflect.get(target, prop);
},
set: function(target, prop, value) {
console.log({ type: 'set', target, prop, value });
return Reflect.set(target, prop, value);
}
}); One more change to be performed is on the plugins that require to change the proxy variable directly in order to reflect the change over the object: private simulate(): void {
this.interval = setInterval(() => {
proxyResource.pi.sensors.pir.value = !this.model.value;
this.showValue();
}, this.localParams.frequency);
this.logger.log(`Simulated sensor ${this.pluginName} sensor Started!`);
} Last step os to establish the WebSocket gateway is formed by a function in charge of accepting connections. Once the WS client connected is able to get data streams from the server once the data is generated. @WebSocketGateway( { transports: ['websocket'] })
export class EventsGateway /*implements OnGatewayConnection, OnGatewayDisconnect*/{
@WebSocketServer() server: Server;
private logger = new Logger(EventsGateway.name);
handleConnection(client: any, ...args: any[]) {
this.logger.log(`New Connection:${args [0]}`);
//this.logger.log(inspect(client))
this.logger.log(inspect(args[0].url))
const url = args[0].url;
this.logger.log(inspect(url));
client.send('Listening data...');
myEvent.on('ws-wot', ()=>{
this.logger.log('Event acquired');
client.send(JSON.stringify(this.selectedResource(url)));
});
}
... For your consideration, the complete example is here |
Hi there, |
TypeError: Object.observe is not a function
at C:_Utilisateur\Project\ObjectIn\webofthings.js\plugins\corePlugin.js:70:
12
at arrayEach (C:_Utilisateur\Project\ObjectIn\webofthings.js\node_modules\l
odash\internal\arrayEach.js:15:9)
at Object. (C:Utilisateur\Project\ObjectIn\webofthings.js\node
modules\lodash\internal\createForEach.js:15:9)
at CorePlugin.observeActions (C:_Utilisateur\Project\ObjectIn\webofthings.j
s\plugins\corePlugin.js:69:5)
at CorePlugin.start (C:_Utilisateur\Project\ObjectIn\webofthings.js\plugins
\corePlugin.js:30:26)
at initPlugins (C:_Utilisateur\Project\ObjectIn\webofthings.js\wot-server.j
s:50:14)
at createServer (C:_Utilisateur\Project\ObjectIn\webofthings.js\wot-server.
js:12:3)
at Object. (C:_Utilisateur\Project\ObjectIn\webofthings.js\wot.j
s:2:1)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (node.js:348:7)
at startup (node.js:140:9)
The text was updated successfully, but these errors were encountered: