Sha256: 9bfeb084c0c9a5a645e06a07292d7985ef9ba80ce919b1f0f7f98fddebb7ef71
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module Beryl class BackendRuntime attr_reader :state def initialize(state, view) @messages = [] @state = state @view = view @commands = [] end def push(message) @messages << message end def process_all_messages while @messages.any? message = @messages.shift result = transition(message.first, message.last) @state = result.is_a?(Array) ? result.first : result command = result.is_a?(Array) ? result[1] : nil run_command(result[1], result[2]) if command if @commands.any? while @commands.any? do end # TODO: refactor process_all_messages end end end def run process render end def run_command(type, payload) puts 'running command' end def transition(type, payload) case type when :IncrementClicked @state.merge(counter: @state[:counter] + 1) when :LoadClicked [@state, :FetchData, key_1: 1, key_2: 2] when :LoadSuccess @state.merge(content: payload[:data]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
beryl-0.3.1 | lib/beryl/backend_runtime.rb |
beryl-0.3.0 | lib/beryl/backend_runtime.rb |