Created
February 21, 2013 07:32
-
-
Save jamonholmgren/5002939 to your computer and use it in GitHub Desktop.
messages_screen.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessagesScreen < ProMotion::TableScreen | |
title "Messages" | |
def on_appear | |
poll_server | |
end | |
def table_data | |
@table_data ||= [{ title: "", cells: [] }] | |
end | |
def poll_server | |
ServerPoller.poll_server do |messages| | |
new_cells = messages.map do |m| | |
{ | |
title: m.text, | |
action: :cell_tapped, | |
arguments: { message_id: m.id } | |
} | |
end | |
@table_data = [{ | |
title: "", | |
cells: new_cells | |
}] | |
end | |
end | |
def cell_tapped(data={}) | |
data[:message_id] | |
# there's your message id, or just pass in the whole message if you want. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment