goinstant / goangular

AngularJS bindings for GoInstant. Build realtime, multi-user apps with AngularJS and GoInstant easily. https://developers.goinstant.com/v1/GoAngular/index.html
BSD 3-Clause "New" or "Revised" License
137 stars 30 forks source link

Users Implementation #18

Closed mattcreager closed 10 years ago

mattcreager commented 11 years ago

Users will be a convenience method for key('/.users'):

angularApp.controller('Ctrl', function($scope, goConnection) {
  var connectionPromise = goConnection.ready();

  connectionPromise.then(function() {
    var lobby = goConnection.room('lobby');  // lobby is joined by default
    var usersPromise = lobby.users.get();  // Returns a promise

    usersPromise.then(function(userObj) {
      // You have your users object
    }).finally($scope.$apply);
  });
});
robinboehm commented 11 years ago

Why the API defines: I) room('lobby') & lobby.users.get()

and not: II) room('lobby') & lobby.users()

or: III) room('lobby').get() & lobby.users.get()?

Inconsistent API here? I would prefer option II).

mattcreager commented 11 years ago

I'd propose we first align with the GoInstant Room API:

var usersKey = lobby.users; // users is just a convenience method for key('/.users')

usersKey.get().then(function...  

and perhaps then design a higher level API providing access directly to users via. a service?

mattcreager commented 10 years ago

This change has been made redundant by the introduction of promises to the GoInstant API!