Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
Created February 21, 2013 07:32
Show Gist options
  • Save jamonholmgren/5002939 to your computer and use it in GitHub Desktop.
Save jamonholmgren/5002939 to your computer and use it in GitHub Desktop.
messages_screen.rb
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