
UsersCache = (authd-ws, on-user) ->
	self = {}

	on-user ||= (user) ->

	# uid => user
	self.users = {}

	authd-ws.add-event-listener \user, (message) ->
		user = message.user

		self.users[user.uid] := user

		on-user user

	self.get-user = (uid) ->
		if user = self.users[uid]
			user
		else
			console.log "Sending request for #{uid}"
			authd-ws.get-user uid

	self

module.exports = UsersCache

