frintjs / frint-props

Compose reactive props in FrintJS applications
https://frint.js.org
MIT License
12 stars 1 forks source link

frint-props: create first functions #4

Closed fahad19 closed 6 years ago

fahad19 commented 6 years ago

This function, along with unit tests, will be the base for other functions to follow.

There will be two kinds of functions:

  1. That adds props
  2. That processes/transforms the props

One that adds props, will look like this:

function withFoo() {
  // the returned function here follows same API as the function that `observe` HoC receives
  return function (app, props$) {
    // value returned from here will be merged to final props stream
    return {
      foo: 'foo value here',
    };
  };
}

One that transforms the props further (API still a WIP):

function capitalizeFoo() {
  return function (app, props$) {
    // return a function for processing
    return function (processedProps) {
      processedProps.foo = processedProps.toUpperString();

      return processedProps;
    };
  };
}
fahad19 commented 6 years ago

Depends on #3