Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP accumulator.resolve api #15

Closed
acatl opened this issue Oct 25, 2017 · 2 comments
Closed

WIP accumulator.resolve api #15

acatl opened this issue Oct 25, 2017 · 2 comments

Comments

@acatl
Copy link
Collaborator

acatl commented Oct 25, 2017

SPEC IS WORK IN PROGRESS

This feature would allow a reducer to resolve a transform at different levels. This means a transformation can be prematurely exited with a given value or it can be resolved to a new entity id.

API:

Resolve the current Transform with:

  • given value: accumulator.resolveTransformWith(value:*)
  • given entityId: accumulator.resolveTransformTo(entityId:string)

Implementation examples:

Using accumulator.resolveTransformWith to resolve a transform with a given value.

dataPoint.transform([
    ()=> 'foo',
    (acc) => acc.resolveTransformWith('bar')
    (acc) => 'will not execute'
  ])
  .then( acc => console.log(acc.value) )
  // should output: 'bar'

Using accumulator.resolveTransformTo to resolve a transform to another transform.

dataPoint.addEntities({
  'transform:foo': () => 'foo',
  'transform:bar': () => 'bar'
})

dataPoint.transform([
    ()=> 'useFoo',
    (acc) => {
       acc.value === 'useFoo'
         ? acc.resolveTransformTo('transform:foo')
         : acc.resolveTransformTo('transform:bar')
    }
  ])
  .then( acc => console.log(acc.value) )
  // should output: 'foo'
@raingerber
Copy link
Contributor

I don't think we should implement the accumulator.resolveTransformTo method, because it makes entity resolution much more unpredictable. Currently we can look at the static definitions and figure out the possible resolution paths (even with control entities), but that would be much more difficult if resolveTransformTo is being used (or even impossible if the method gets passed a dynamic entityId using a variable).

@acatl acatl moved this from To Do to Draft in data-point Dec 13, 2017
@acatl acatl moved this from Draft to To Do in data-point Dec 13, 2017
@acatl
Copy link
Collaborator Author

acatl commented Dec 31, 2017

will not do for now

@acatl acatl closed this as completed Dec 31, 2017
data-point automation moved this from To Do to Done Dec 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
data-point
  
Done
Development

No branches or pull requests

2 participants