question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use .of(namespace)?

See original GitHub issue

Hi! i was trying to use .of(namespace) but I could not figure out how to use it.

When I injected Socket in my Angular Service and called .of(‘myNamespace’) on the WrappedSocket instance I got the error:

ERROR TypeError: this.ioSocket.of is not a function at WrappedSocket.push../node_modules/ngx-socket-io/src/socket-io.service.js.WrappedSocket.of (socket-io.service.js:21)

It would be great to have a little documentation / an example about how to use this function.

Thank you!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:13
  • Comments:17

github_iconTop GitHub Comments

12reactions
seba-salavillacommented, Apr 4, 2019

In socketservices you can use this.socket.ioSocket.nsp = “/mynamespace” only if you have a manually connection.

4reactions
Kuppusamy-Rcommented, Apr 4, 2020

Hi there,

I’ve achieved namespace like below ,

import { Socket, SocketIoConfig } from 'ngx-socket-io';

export class SocketNameSpace extends Socket{
  constructor(socketConfig: SocketIoConfig){
    super(socketConfig);
  }
}


@Component(........) // metadata goes here
export class MyComponent{
    chat: SocketNameSpace;
    news: SocketNameSpace;

    constructor(private socket: Socket){
        // this.socket is for root
        this.chat  = new SocketNameSpace({url: 'http://localhost:3000/chat',options: {} });
        this.news  = new SocketNameSpace({url: 'http://localhost:3000/news',options: {} });
   }
}

It works fine and awesome!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespace in C++ | Set 1 (Introduction) - GeeksforGeeks
Definition and Creation: Namespaces allow us to group named entities that otherwise would have global scope into narrower scopes, giving them ...
Read more >
Namespaces in C++ - Tutorialspoint
A namespace is designed to overcome this difficulty and is used as additional information to differentiate similar functions, classes, variables etc. with the ......
Read more >
Uses of Namespace in C++ - Simplilearn
Namespaces are regions in a program logically separated from the rest. They are necessary if you want more than one function with the...
Read more >
How do you properly use namespaces in C++? - Stack Overflow
You can either use "use NAMESPACE" which is similar to an "import PACKAGE" statement, e.g. use std. Or you specify the package as...
Read more >
Namespaces - cppreference.com
Namespaces provide a method for preventing name conflicts in large projects. Symbols declared inside a namespace block are placed in a named ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found