Skip to content

Universal functions not everywehere? #212

Answered by dbuezas
elbertov asked this question in Q&A
Discussion options

You must be logged in to vote

TL;DR: The error message explains it

Functions inside entities need to run after the data is fetched, and to know what to fetch, the time_offset needs to be known beforehand. But the time_offsets hasn't ran yet because it's written below the entities.
When you write plain values instead of functions, this order is not enforced because it is known that the value won't change and there won't be any side effects (like storing in vars)

So pretty much this:

Solution

Luckily, the computation you do for the entity's name doesn't depend on the fetched data, so you can extract it and put it above entities:

not_a_prop: $fn ({ vars }) => {.
  ...
  vars.my_title = "...";
  vars.my_time_offset = "...";

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@dbuezas
Comment options

@dbuezas
Comment options

@elbertov
Comment options

@dbuezas
Comment options

@dbuezas
Comment options

Answer selected by dbuezas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants