Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 or v2? #88

Open
luislobo opened this issue Dec 3, 2015 · 6 comments
Open

v1 or v2? #88

luislobo opened this issue Dec 3, 2015 · 6 comments

Comments

@luislobo
Copy link

luislobo commented Dec 3, 2015

Hi,
We are using currently the v1 for our application. I'm wondering if the V2 version should be used and if it is stable enough. What do you think? Is there a plan to release the final version soon?

@TheSharpieOne
Copy link
Contributor

v2 it pretty different than v1. I use v2, but I really don't use all of the feature it offers. I've asked for feedback and issue reports... and the lack of them may mean it good or that no one is using it.

@neonexus
Copy link

I tried using v2 yesterday, and it broke my build, as it doesn't want to use the $sailsProvider.url I've set in my config.

I was also hoping v2 would have exposed socket.io's request() function, but that doesn't seem to be the case (at least, not from what I can tell). I need that function exposed, in-order for this to be a truly drop-in replacement for $http (as one of my custom services is built on $http's request() function).

@TheSharpieOne
Copy link
Contributor

https://docs.angularjs.org/api/ng/service/$http doesn't seem to have a request() function

@neonexus
Copy link

You're right, I realized that a little bit ago, as I was modifying my service. What I was referring to in $http, is using $http(), so I can pass in the method to use, the data, etc. The closest thing to this is request() in socket.io.

@TheSharpieOne
Copy link
Contributor

2.0 still accepts a url through the provider:

var socket = new $sailsIo(provider.socket || provider.url, provider.config);

You also have the ability to create your own socket and pass that to the provider, it will be used instead of creating a new connection.

You can use $sails() just like $http(), it just calls the specific function based on the method specified in the config passed in the call.

function $sails(config) {
return $sails[config.method](config.url, config);
}

The thing you are probably running into is that the socket it a constant connection, to a single server. $http would allow you to sent anywhere, $sails limits it to the socket connection. It seems angular-sails may need to have the ability to set up multiple socket connections (maybe a factory service)? But angular-sails is more or less designed to work with sails, which assumes a single socket endpoint.
Also, in 2.0, you can get to the socket via $sails._socket._socket. $sails._socket is the sails socket.io wrapper, which itself exposes the underlying socket through ._socket.
$sails._socket = socket;

self._socket = io(url || config.url, config);
(or
self._socket = url;
)

@neonexus
Copy link

I understand v2 is supposed to accept an URL through the provider (I dug into the code to make sure), just as v1 does, however, that's what forced me to go back to v1: v2 ignores it for some reason, and uses the domain/port it was served from. I had v1 working, found out about v2; updated to v2 (only calling functions on button presses, pressed no buttons); v2 was attempting to connect to localhost:3000, even though I told it to use localhost:1337, the exact same way v1 does.

As far as $sails(), that's awesome, didn't know, will keep it in-mind.

And the multiple sockets: I don't think that's necessary. It would just be nice to tell the service to hold off on the connection, until it's kicked off manually down the line. Not a need, just a nice-to-have. Only because supplying the HTML attributes for socket.io is impossible when using something like gulp to handle assets. Which makes supplying my own socket handler useless, as I still can't disable the eager beaver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants