Move Obredux::Thunk to separate file
This commit is contained in:
parent
34d569f2a4
commit
2a3d2ec149
4 changed files with 21 additions and 15 deletions
|
@ -1,7 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'obredux'
|
||||
|
||||
require 'actions/load_friends'
|
||||
require 'actions/add_friend'
|
||||
require 'actions/add_friend_message'
|
||||
|
|
|
@ -4,6 +4,9 @@ require 'tox'
|
|||
|
||||
require 'singleton'
|
||||
|
||||
require 'obredux'
|
||||
require 'obredux/thunk'
|
||||
|
||||
require 'helpers'
|
||||
require 'actions'
|
||||
require 'reducer'
|
||||
|
|
|
@ -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
18
lib/obredux/thunk.rb
Normal 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
|
Reference in a new issue