Archived
1
0
Fork 0

Move Obredux::Thunk to separate file

This commit is contained in:
Braiden Vasco 2017-08-12 02:32:29 +00:00
parent 34d569f2a4
commit 2a3d2ec149
4 changed files with 21 additions and 15 deletions

View file

@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'obredux'
require 'actions/load_friends'
require 'actions/add_friend'
require 'actions/add_friend_message'

View file

@ -4,6 +4,9 @@ require 'tox'
require 'singleton'
require 'obredux'
require 'obredux/thunk'
require 'helpers'
require 'actions'
require 'reducer'

View file

@ -13,19 +13,6 @@ module Obredux
end
end
class Thunk < Middleware
def call(store, action)
return action unless action.is_a? Action
action.call store.public_method :dispatch
end
class Action < Action
def call(_dispatch)
raise NotImplementedError, "#{self.class}#call"
end
end
end
class Store
attr_reader :reducer_klass, :state, :middleware

18
lib/obredux/thunk.rb Normal file
View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'obredux'
module Obredux
class Thunk < Middleware
def call(store, action)
return action unless action.is_a? Action
action.call store.public_method :dispatch
end
class Action < Action
def call(_dispatch)
raise NotImplementedError, "#{self.class}#call"
end
end
end
end