Happy holidays, everyone!
I need a way to generate a globally unique identifier that I can access within the same layout iteration. My current approach looks like this:
#let id = state("refsection-id", "ref")
#context {
id.update(x => x + "_1")
// <-- here
}
// <-- or here
One could alternatively use a counter, I suppose. I don’t particularly care what the identifier looks like, as long as I can access it as a string or int and it is globally unique to the document. I store it in a state and access it throughout a specific region of a document.
Now my question is: Can we find any way in which I can access the updated value of the state/counter at either of the two locations marked with “here” in the code snippet - within the same layout iteration in which the value is updated?
Obviously I can do it with a get, but my understanding is that this get call will only return the correct value in the next layout iteration. My code already uses four layout iterations in the worst case, and I don’t think I can afford this. state.update and counter.step both return content, which doesn’t seem to contain the updated value even in its fields.
Any thoughts?