angular - How to act on callback function -


i have script connects server using websocket

export class appcomponent {    connection_status = false;   message = '';    public connect() {     this.socket = io('http://localhost:5001');     this.socket.on('connected', this.connection_established);   } } 

i change connection_status variable when connected message received , save content of message message variable.

export class appcomponent {    connection_status = false;   message = '';    public connect() {     this.socket = io('http://localhost:5001');     this.socket.on('connected', this.connection_established.bind(this));   }    connection_established() {     this.connection_established = true;     this.message = 'connected';   } } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -