feathersjs-ecosystem / socketio

[MOVED] The Feathers Socket.io websocket transport plugin
https://github.com/feathersjs/feathers
MIT License
37 stars 14 forks source link

Get data after connection established #59

Closed rrubio closed 7 years ago

rrubio commented 7 years ago

Hi Guys,

This might be a super dumb question, but here it goes.

As per example provided under this repository, my client is able to connect fine and i do get a response from "socket.emit('news', { hello: 'world' });".

How do i go about CRUD, fetching data from the example provided? is there an example somewhere? I haven't been able to use feathers-client on my app due to some errors under "ionic", i'm using vanilla socket.io syntax (see below)

`this.messages = []; this.socketHost = "http://localhost:3030"; this.zone = new NgZone({enableLongStackTrace: false});

    this.chatBox = "";
    this.socket.socketService.subscribe(event => {
    console.log('message received from server... ', event);
    if (event.category === 'messages'){
      this.zone.run(() => {
        this.messages.push(event.message);
        this.chat.scrollTo(0, 99999, 0);
      });
    }
  }); //end of subscribe`
daffl commented 7 years ago

What was the error you were getting? We do recommend using the client if possible and Feathers client should work in most JavaScript environments.

Either way, you can find documentation for direct socket.io communication at https://docs.feathersjs.com/clients/vanilla-socket-io.html.

rrubio commented 7 years ago

Thank you @daffl, hand't seen the vanilla doco.

I didn't keep the exact message, but it was something along the lines of an emit error due to no export under the feathers-client library. This is on ionic framework "ionic2".

daffl commented 7 years ago

Did you load feathers-client/dist/feathers or just feathers-client?

rrubio commented 7 years ago

feathers-client only, should i try with "dist"?

daffl commented 7 years ago

feathers-client itself will only work with a module loader that works with npm. Anything else will should use the pre-built UMD wrapped distributable.

rrubio commented 7 years ago

Cool! thank you. Here's the tutorial i tried following, I am using angular 2 keep in mind that i'm implementing onto ionic not a webapp (https://berndsgn.ch/angular2-and-feathersjs/). I'll try and recreate the message this week.

daffl commented 7 years ago

Sounds good. Please open a new issue if you still get an error and can recreate it with a small breaking example.