### File

`src/lib/socket-io.module.ts`

### Deprecated

use the provideSocketIo function instead

### Methods

Static forRoot
`forRoot(config: SocketIoConfig)`
Defined in src/lib/socket-io.module.ts:23
Parameters :
Name | Type | Optional
config | `SocketIoConfig` | No
Returns : `ModuleWithProviders<SocketIoModule>`

    import {
      InjectionToken,
      ModuleWithProviders,
      NgModule,
    } from '@angular/core';
    import { SocketIoConfig } from './socket-io.config';
    import { WrappedSocket } from './socket-io.service';

    /** Socket factory */
    export function SocketFactory(config: SocketIoConfig) {
      return new WrappedSocket(config.url, config.options);
    }

    export const SOCKET_CONFIG_TOKEN = new InjectionToken<SocketIoConfig>(
      'rxap-socket-io/config',
    );

    /**
     * @deprecated use the provideSocketIo function instead
     */
    @NgModule({})
    export class SocketIoModule {
      static forRoot(config: SocketIoConfig): ModuleWithProviders<SocketIoModule> {
        return {
          ngModule: SocketIoModule,
          providers: [
            {
              provide: SOCKET_CONFIG_TOKEN,
              useValue: config,
            },
            {
              provide: WrappedSocket,
              useFactory: SocketFactory,
              deps: [ SOCKET_CONFIG_TOKEN ],
            },
          ],
        };
      }
    }

# results matching ""

# No results matching ""