-
Make sure you have custom templates directory at:
~/Library/Developer/Xcode/Templates/File\ Templates/Custom
if not create it. -
Next copy
*.xctemplate
intoCustom
folder, that's it.
This template will create 3 files: for state itself, actions and reducer.
import ReSwift
struct AwesomeState: StateType {
// state goes here
}
extension AwesomeState: Equatable {
static func == (lhs: AwesomeState, rhs: AwesomeState) -> Bool {
// compare goes here
}
}
import ReSwift
enum AwesomeActions: Action {
// actions goes here
}
import ReSwift
class AwesomeReducer {
func reducer(action: Action, state: AwesomeState?) -> AwesomeState {
var state = state ?? AwesomeState()
guard let action = action as? AwesomeActions else {
return state
}
// process actions
return state
}
}