#Getter vs. Arrow function

1 messages · Page 1 of 1 (latest)

crimson valley
#

These different codes eventually produce different dialogs in my Glimmer app , see enclosed images:
(1)get imdbDirName() { let tmp = this.z.imdbDirName; return this.z.handsomize2sp(tmp); }(2)imdbDirName = () => { let tmp = this.z.imdbDirName; return this.z.handsomize2sp(tmp); }More: this.z.imbDirName is a getter in the “z“ service. What did I miss when expecting to see the same result? Note: Herethis.imdbDirName is defined.
What may be the reason for the different outcome?

real turtle
#

what is your template code?

#

getters and functions have different template expectations

#

as in, functions are not automatically invoked unless you use invocation syntax

#

getters are "just properties" that have a body that's evaluated on each access

crimson valley
real turtle
#

right, the () for an invocation are only needed when you have no args -- for disambiguation

crimson valley
real turtle
#

what is arrow?

crimson valley
real turtle
#

can you share code?

crimson valley
real turtle
#

why so many single letter variables?

#

L 331 is triple {{{ that's dangerous, and could open you up to a security vuln if any user or server input is rendered there

#

need to sanitize that before rendering

crimson valley
#

Is triple { dangerous without ( )? What is “need to sanitize that before rendering“? I really do care for safety. Advice me, please!