Coder Social home page Coder Social logo

Comments (16)

germain171 avatar germain171 commented on August 15, 2024 4

Hi all, very new to this dev stuff. so dont mind my silly question.
i get this, when 'possibly' using the newest version of Chrome to debug a Mobile device. which i think is on an older version of chrome wrapped in an Industrial Browser.
Uncaught TypeError: Object.observe is not a function at WebInspector.Main._createSettings (inspector.js:10452) at WebInspector.Main._gotPreferences (inspector.js:10444) at DevToolsAPIImpl.embedderMessageAck (devtools_compatibility.js:33) at <anonymous>:1:13
When using command navigator.appVersion.match(/.*Chrome\/([0-9\.]+)/)[1] in the dev console with the remote browser connected, i get the dev console version of 72.0.3626.109.
so at this point i cannot even interrogate what the version of chrome/ind browser. To see if it is a version compatibility issue.
My current plan, and its not a great one. Is to download and install Chrome from a random guess age in the past and keep downloading older ones until it works. ( i dont like this fix)

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 ?

from webofthings.js.

franckOL avatar franckOL commented on August 15, 2024

Found that https://github.com/anywhichway/proxy-observe , but seem too heavy

from webofthings.js.

domguinard avatar domguinard commented on August 15, 2024

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().

from webofthings.js.

franckOL avatar franckOL commented on August 15, 2024

Hi,
What about the pull request, it works for all version of node js, and it's really minor change.
Franck

from webofthings.js.

domguinard avatar domguinard commented on August 15, 2024

Sorry about that Franck, we missed the PR. This is really simple and great. I just accepted the PR, thanks a lot!

from webofthings.js.

domguinard avatar domguinard commented on August 15, 2024

Reopening as the new Node LTS is now 6 we'll be looking into this.

from webofthings.js.

ngmgithub avatar ngmgithub commented on August 15, 2024

Running the latest commit in master as of today. Still seeing the Object.observe is not a function issue.

webofthings/wot-book@9ab17ed

Running Node v6.10.0 over nvm

from webofthings.js.

developer-tarun avatar developer-tarun commented on August 15, 2024

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

from webofthings.js.

domguinard avatar domguinard commented on August 15, 2024

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)

from webofthings.js.

logivity avatar logivity commented on August 15, 2024

Any update on this?

from webofthings.js.

ngmgithub avatar ngmgithub commented on August 15, 2024

from webofthings.js.

domguinard avatar domguinard commented on August 15, 2024

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.

from webofthings.js.

franckOL avatar franckOL commented on August 15, 2024

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 ?

from webofthings.js.

ngmgithub avatar ngmgithub commented on August 15, 2024

@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?

from webofthings.js.

aolite avatar aolite commented on August 15, 2024

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 Object.observer().

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

from webofthings.js.

DavidGomez-dev avatar DavidGomez-dev commented on August 15, 2024

Hi there,
Maybe not the best solution, but some idea for a simple one.
I used the own resources.json as a simple database.
In the plugin I used readFile and a setInterval to check the value with some frequency.
Then on the actuator router, I used readFile and writeFile to update the value on the json according to the PUT value of the call.
Just another idea.

from webofthings.js.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.