All Projects → joeherold → angular2-sails

joeherold / angular2-sails

Licence: MIT license
An angular module for using the sails socket.io api in angular2 (@angular)

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to angular2-sails

sails-hook-multitenant
A multitenant Sails.js 1.X hook for Waterline ORM.
Stars: ✭ 15 (-59.46%)
Mutual labels:  sailsjs, sails
sails-token-auth-setup
Token based authentication installation guide
Stars: ✭ 24 (-35.14%)
Mutual labels:  sailsjs, sails
live-stream-media-source-extensions
Live stream h264 encoded mp4 video on media source extensions using ffmpeg, node.js, socket.io, and express. Works in chrome, firefox, safari, and android. Not iOS compatible. Work has moved to mse-live-player repo =>
Stars: ✭ 24 (-35.14%)
Mutual labels:  socket-io
opentelemetry-ext-js
js extensions for the open-telemetry project
Stars: ✭ 122 (+229.73%)
Mutual labels:  socket-io
io-game
Synchronizing various RPG elements over the network with sockets.
Stars: ✭ 17 (-54.05%)
Mutual labels:  socket-io
Nodhat
Simple Node.js Chat Application
Stars: ✭ 13 (-64.86%)
Mutual labels:  socket-io
bubbly
Full stack chat application created w/ Next.js, Socket.IO, Express, React and TypeScript
Stars: ✭ 24 (-35.14%)
Mutual labels:  socket-io
FastAPI-Full-Stack-Samples
The API Application Development using Python FastAPI, including interactive API documentation
Stars: ✭ 61 (+64.86%)
Mutual labels:  socket-io
syncwatch
Browser extension to watch videos together
Stars: ✭ 48 (+29.73%)
Mutual labels:  socket-io
les-chat
Real-time messenger with private, public & group chat. Made using PERN + GraphQL stack.
Stars: ✭ 48 (+29.73%)
Mutual labels:  socket-io
FlyingChat
即时聊天系统
Stars: ✭ 26 (-29.73%)
Mutual labels:  socket-io
web09-Duxcord
🦆 오리들은 한다 협업을 꽥!! 🦆
Stars: ✭ 51 (+37.84%)
Mutual labels:  socket-io
ionic-uuchat
基于ionic3,angular4的实时聊天app,兼容web端。该项目只是前端部分,所有数据需要请求后端服务器,需要配套express-uuchat-api使用。
Stars: ✭ 14 (-62.16%)
Mutual labels:  socket-io
Socketify
Raw TCP and UDP Sockets API on Desktop Browsers
Stars: ✭ 67 (+81.08%)
Mutual labels:  socket-io
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (+86.49%)
Mutual labels:  socket-io
Video-Chat
Video calling and chatting app (PWA) built using React.js, Web RTC and Socket.io
Stars: ✭ 305 (+724.32%)
Mutual labels:  socket-io
django-channels-with-socket.io
django channels with socket.io
Stars: ✭ 23 (-37.84%)
Mutual labels:  socket-io
chat
A simple chat app built with Node/React
Stars: ✭ 24 (-35.14%)
Mutual labels:  socket-io
aircnc
☕ Airbnb like (Air Coffee & Code) to booking spots for developers using ReactJS, React Native, Node.js and more.
Stars: ✭ 37 (+0%)
Mutual labels:  socket-io
react-webrtc-chat
React WebRTC chat
Stars: ✭ 39 (+5.41%)
Mutual labels:  socket-io

important

This repo is no longer maintained! We switched to React JS completely. Feel free to fork this repo.

angular2-sails

An angular module for using the sails socket.io api in angular2 (@angular)

Read the full documentation at: Documentation @ gitbook.com

INDEX

Usage with angular-cli

Angular-cli is a great angular2 app starter for creating fancy angular stuff.

Here I will describe on how to install and use it:

1. Installing

install the package with the node package manager (npm)

npm install --save angular2-sails

back to top

2. Using it

in app.module.ts import and register the angular2-sails module like that:

...
import { AppComponent } from './app.component';
import {SailsModule} from "angular2-sails";


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    SailsModule.forRoot()
  ],

  bootstrap: [AppComponent]
})
export class AppModule { }

back to top

working with it

You inject the service by the constructor where you want to use it.

constructor(private _sailsService:SailsService) { }

first you have to connect your service:

ngOnInit() {
    this._sailsService.connect()
}

you can pass in an Url or Options, where to connect to

ngOnInit() {
    this._sailsService.connect("http://localhost:1337");
    // or
    letl opts = {
        url: "http://localhost:1337",
        transports: ['polling', 'websocket'],
        headers: {...},
        ...
    }
    this._sailsService.connect(opts);
}

for more information, please visit sailsjs.org Documentation for SailsSocket Properties

this is handy, when you develop with angular-cli (localhost:4200) and the ng serve command and your sails app runs separately e.g on localhost:1337

The following methods are implemented in the SailsService and will always return you an Observable:

  • get(path,data):Observable
  • post(path,data):Observable
  • put(path,data):Observable
  • patch(path,data):Observable
  • delete(path,data):Observable
  • request(options):Observable
  • on(eventEntity):Observable

for more information, please visit sailsjs.org Documentation for SailsSocket Methods

You then have to subscribe to that Observable, to get the data.

back to top

IMPORTANT NOTES

io (sails.io.js)

I was asked couple of times, why one gets an error like (io is not defined). So to clear things up a bit. The io library (sails.io.js) is not part of this module. So that's why you have to add io (sail.io.js) yourself to your project. Otherwise io will not be defined as a global varable and will not be accessible.

There are several ways to do so:

by script tag

One is to link the sail.io.js in your index.html or layout.ejs as a simple script tag.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Sailsapp</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root>Loading...</app-root>

  <!-- add the io library -->
  <script src="/assets/sails.io/sails.io.js"></script>
</body>
</html>

angular-cli (webpack version)

When you are using angular-cli (what is my recommendation), then you can add the file to the scripts array of your angular-cli.json.

// ANGULAR_CLI_ROOT/angular-cli.json
{
  "project": {
    ...
  },
  "apps": [
    {
      ...
      "styles": [
        "styles.less"
      ],
      "scripts": [
      	"../path/to/sails.io.js" //this is where you may add the io library
      ],
      ...
    }
  ],
  ...
}

plain webpack

When you are using webpack, you also could add the sails.io.js file to your project by installing the library and requireing it.

back to top

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].