Первый аргумент Bind изменяет ключевое слово this
.Вам просто нужно вызвать здесь, так как функция в любом случае карри:
const WeatherAction = Action('weather');
const WeatherActionSub = WeatherAction('sub');
const WeatherActionUnSub = WeatherAction('unsub');
const test = WeatherActionSub({test: 'test'});
console.log(test);
(Действительный код привязки, который довольно бессмысленный, потому что вызов без аргументов должен следовать:)
const WeatherAction = Action.bind(null, 'weather')();
const WeatherActionSub = WeatherAction.bind(null, 'sub')();
const WeatherActionUnSub = WeatherAction.bind(null, 'unsub')();
Если бы функция была неиспользованной, имеет смысл связать:
const ActionUncurried = (channel: string, action: string, payload: object) => {
return Object.assign({},payload,{channel: channel, action: action});
};
const WeatherAction = ActionUncurried.bind(null, 'weather');
const WeatherActionSub = WeatherAction.bind(null, 'sub');
const WeatherActionUnSub = WeatherAction.bind(null, 'unsub');
const test = WeatherActionSub({test: 'test'});
console.log(test);