Looking up objects outside of state #75
Replies: 3 comments 4 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
I guess the question becomes which value takes priority? the current behavior is always read from state. to avoid a breaking change it would need to be
|
Beta Was this translation helpful? Give feedback.
-
|
We ended up going with As a result, a look up value can use chain
.lookup({
key: 'world'
, alt: 'bill'
, name: 'hello {{#this.key}} {{#this.alt}}'
, output: '!template:#this.name'
, array: [{
deep: 'yes'
, works: '#this.deep'
}, {
deep: 'no'
, works: '#this.deep'
, templated: '!template:"templated {{#this.deep}}"'
}]
, pluck: '#this.array.0.works'
, nested: {
objects: {
here: 'there'
, there: '#this.here'
}
}
})yields {
key: 'world',
alt: 'bill',
name: 'hello {{#this.key}} {{#this.alt}}',
output: 'hello world bill',
array: [
{ deep: 'yes', works: 'yes' },
{
deep: 'no',
works: 'no',
templated: 'templated no'
}
],
pluck: 'yes',
nested: {
objects: { here: 'there', there: 'there' }
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There is a common pattern emerging with default values for chain actions that has exposed a pain point with the
lookupfunctioncalling this function, I would generally expect this to "just work", but the
slugvalue is never populatedThe problem here is that the
lookupfunction assumes that all values exist in state, however in the case of defaults above, that is not true. As a work around people will generally (ab)use.setto work around this short comingWorkable, but not every intuitive and a bit clunky. What we could do is either
@for examplethis operator
this keyword
Beta Was this translation helpful? Give feedback.
All reactions