Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit e46a996

Browse files
authored
added comments
1 parent fd976d7 commit e46a996

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hyper-operation/chat-app/app/hyperloop/stores/message_store.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
# The MessageStore provides three class level methods all of which are reactive:
2+
# MessageStore.all - returns all messages
3+
# MessageStore.user_name - return current user name
4+
# MessageStore.online? - is the application connected
5+
16
class MessageStore < Hyperloop::Store
27
state :messages, scope: :class, reader: :all
38
state :user_name, scope: :class, reader: true
49

5-
def self.online?
10+
def self.online?
11+
# for purposes of our toy app we are online once messages gets set
612
state.messages
713
end
814

15+
# The store listens for dispatches from our operations and updates
16+
# state accordingly. Notice that the Operation interface works the
17+
# same regardless if the Operation is running remotely or locally.
18+
919
receives Operations::Join do |params|
1020
puts "receiving Operations::Join.run(#{params})"
1121
mutate.user_name params.user_name

0 commit comments

Comments
 (0)