Perspective: Binding efficiency between using Expression and Indirect Tag + Expression tranform

v8.1.0

What’s more efficient and more performant for bindings:

  1. Using an expression binding for example: toBoolean(tag('tag/path/' + {parameterX}))
  2. Using an indirect tag binding and then applying an expression transform, e.g.:
    a)tag indirect binding: tag/path/{1}, {1} => {parameterX}
    b)expression transform: toBoolean({value})

I’ll channel my inner pturmel and say don’t use the tag function. It’s better to create an indirect binding. If you need more than one tag in an expression binding you’re better off creating indirect bindings on custom properties and using those instead.

1 Like

I knew Phil would most likely say that :laughing: I guess I wondered if it’s still the most efficient in Perspective as well

1 Like

My answer is a little more nuanced in Perspective if using structure bindings:

Otherwise, yes, use indirect bindings.

Please take a look at my new post, " Perspective property binding with expression transform behaves differently than equivalent expression"

I could use your input. Thanks.

There is great content in this thread, so I would like to extend the question a bit:

  • Given there is a Perspective label component intended to display a tag’s value
  • Given this label’s text property is bound to view.custom.tagValue through a Property binding

@pturmel Which type of binding is best regarding performance for the view.custom.tagValue property to accommodate a dynamic tag-path (if there is a difference):

Option 1: A Tag Binding using “Indirect”, such as {tagPath}+'/static/portion/of/path', where tagPath is a reference and the property is {view.params.tagPath}

Option 2: A Tag Binding using “Expression”, such as {view.params.tagPath}+'/static/portion/of/path'

Isn’t this the same question as my OP? Your option 2 wouldn’t work as you expect btw, it will literally just return a string with your tag path. If you want to actually read the tag path in the expression language you would need to use tag()
My bad

I didn’t think so, but maybe I’m wrong. I thought your question was the difference between the following:

  1. Label text with expression Binding tag('tag/path/' + {parameterX})
  2. Label text with Tag binding “Indirect”: tag/path/{1} , {1} => {parameterX}

I’m asking about option 3:
3. Label text with Tag binding Expression 'tag/path/' + {parameterX}

Why wouldn’t Option 2 in my post above work using a TagBinding with expression?
image

Oohh, I always forget that there’s that new tag binding option in 8. I thought you were talking about an expression binding itself. Awks :sweat_smile: now I’m intrigued as to the answer as well

All ‘tag’ binding types in Perspective are ultimately using the same code to create the binding, so there’s not really going to be any significant difference. I would use an indirect tag binding unless you specifically need the extra ‘power’ of an expression there.

The advice to avoid tag() still stands.

3 Likes

I really don’t need the extra power of an expression but if there is only one property, then I prefer expressions over the indirect tag binding because it is quicker to implement a binding; the expression tag binding doesn’t need a middle-man reference variable.

image

vs

image

Thanks for the clarification.

This is where i tend to just use the old number-based method we were always forced to use pre-8. It’s far quicker to type and I don’t find adding a text description offers much since the most I’ve ever tried to reference out was 2, maybe 3 parts. If you’re doing more than that, then it should probably be moved out into a custom property so that you can reuse it multiple times without having to reference those same 3,4,5+ references everywhere you need them inside of indirect tag bindings:

tag/path/{1}

There is a slight performance advantage to using a ‘middleman’ with an indirect binding. That is, it avoids setting up an expression context and executing it on every update of the binding.

3 Likes

2 posts were split to a new topic: Indirect tag binding setup