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

Add local store #54

Closed
dblock opened this issue Jan 27, 2016 · 0 comments
Closed

Add local store #54

dblock opened this issue Jan 27, 2016 · 0 comments

Comments

@dblock
Copy link
Collaborator

dblock commented Jan 27, 2016

There's an interesting implementation in https://github.com/slackhq/node-slack-client/blob/master/src/client.coffee that caches users, channels, ims and groups.

        for k of data.users
          u = data.users[k]
          @users[u.id] = new User @, u

It then does a lot of bookkeeping for you listening to well-known slack events.

      when "team_join", "user_change"
        u = message.user
        @emit 'userChange', u
        @users[u.id] = new User @, u

Slack::RealTime::Client should implement similar behavior, possibly optionally.

The 2.0 branch does this even better with a clearly defined local store abstracted away.

We want to start with a local store

module Slack
  module RealTime
    module Store
      class Memory
        attr_accessor :users
        attr_accessor :channels
        attr_accessor :dms
        attr_accessor :groups
        attr_accessor :bots
        attr_accessor :teams

        def initialize
          @users = {}
          @channels = {}
          @dms = {}
          @groups = {}
          @bots = {}
          @teams = {}
        end
      end
    end
  end
end

And implement a set of handlers like https://github.com/slackhq/node-slack-client/tree/2.0.0-beta/lib/data-store/message-handlers that manipulate the store.

@dblock dblock changed the title Cache server-side user, groups, channels and other data on launch Cache and maintain user, groups, channels and other data Jan 27, 2016
@dblock dblock changed the title Cache and maintain user, groups, channels and other data Add local store Jan 27, 2016
dblock added a commit that referenced this issue Jan 30, 2016
@dblock dblock mentioned this issue Jan 30, 2016
dblock added a commit that referenced this issue Feb 2, 2016
@dblock dblock closed this as completed Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant