realar-project / realar

5 kB Advanced state manager for React
MIT License
44 stars 0 forks source link

low: flow.to proposal #72

Closed betula closed 3 years ago

betula commented 3 years ago

sharedLocale().lang.flow.to(formattedTextOverStyles, (curr_code, curr_styles?, prev_code?) => {
  const data = getInstructionData() as any;
  return data['styles_' + code] || {};
});

// No use `on` inside, use only `flow`
// No possible because flow not used subscription, its necessary for making flow body, not a flow intersections
const to = (src, target, fn) => {
  const [get] = flow((stop, prev_code) => {
    fn(src.val, target.val, prev_code)
  });
}

// Hmmmmmm, but `on` impl: ->
const to = (src, target, fn) => {
  on(src, (v, prev_v) => {
    target.set(fn(v, target.get(), prev_v))
  });

  const [get] = flow((stop, prev_code) => {
    fn(src.val, target.val, prev_code)
  });
}

// And update reactive-box API:

sell((prev_value?) => {

});
flow(init_, (stop?, prev_value?) => {

});
betula commented 3 years ago

"flow.to" implemented as "update.by" in 0.6.0 <T>(re: Re<Will<T>>, updater?: (state: O, reValue: T, rePrev: WillExpand<Will<T>>) => I)