# angular-socket

> ### Installation

Latest version **0.0.5** (published 2021-05-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install angular-socket
pnpm add angular-socket
yarn add angular-socket
bun add angular-socket
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2021-05-09 |
| First published | 2021-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 138.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ashish K |
| Maintainers | codewithashish |
| Keywords | angular, socket io, socket.io, angular socket, socket angular, socket, web sockets, websockets |

## Links

- npm: https://www.npmjs.com/package/angular-socket
- npm.io page: https://npm.io/package/angular-socket

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.10.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2021-05-09
- 0.0.4 — 2021-05-08
- 0.0.3 — 2021-05-08
- 0.0.2 — 2021-05-08
- 0.0.1 — 2021-05-08

## README

### Angular socket io Documentation

### Installation

`npm install angular-socket`

### import AngularSocketModule in app.module and inject as a Root

```ts
import { AngularSocketModule } from 'angular-socket';

const config = { url: 'http://localhost:9898/', options: {} };
 imports: [
    AngularSocketModule.forRoot(config)
  ]
```

### use socket service in component

Import AngularSocketService in component

```typescript
import { AngularSocketService } from 'angular-socket';
constructor(private socketServiceObj: AngularSocketService) {}

sendMessage(msg: string) {
    this.socketServiceObj.emit('message', msg);
}
receiveMessage() {
    this.socketServiceObj.on('message', (receivedMessage) => {
      console.log(receivedMessage);
    });
}
```

### Note: In case you are facing CORS errors in your angular app while getting socket library. Just allow cors from your server to * or to particular domain like this:

```javascript
const socketServer = require('http').Server(app);
const io = require('socket.io')(socketServer, {
  cors: {
    origin: 'your client domain',
  }
});
socketServer.listen(9898);
```

---
_Source: https://npm.io/package/angular-socket · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
