Andreas, what Ysrael lately proposed to me I repeat to you: “we should have a beer or two together”. I highly value your comments, but I still have a couple of black spots in, probably, the conceptual understanding of the new rendering. Here we go:
I assume from documentation that:
- we have no influence over the decision making model that Wix uses to run something client or server side (unlike something like runat=“server”): the properties .rendercycle and .env are read-only
- the decision model is opaque to us (which piece of code runs where)
- if you can run something at client or server, you have 4 combinations. We can, for obvious reasons, exclude the option “not at client/not at server”)
- from documentation, I deduce that we can eliminate another option: server only
- this leaves us with two possibilities; at the client only or both at client and server
Now the deduction:
the combination of 1 and 5 dictates that the use of the .env to regulate whether to write something to a collection is flawed: we cannot control the process and if you write something from “browser” to a collection, the same might already have happened on “server”. That is why Wix offers the .rendercycle: you don´t know if it is going to be rendered client side or client-and-server side, but you DO know you only want something to take place only once (rendercycle===1)
Considerations
It might be so that the rendering process is only implemented for formFactor=== Mobile. That would mean that on “Desktop”, .redercycle always = ? and .env always “Browser”. Maybe that is my problem, that .renderCycle always returns Nan on desktop. I do not know. I have a presentation on Friday and with the .rendercycle commented out, it is good enough for that day. I will test further during weekend/next week.
I would appreciate anyone to comment on my assumptions and deduction (like 1:false [comment], 2: true, etc), so I can wrap my head around the concept better. Thanks.
EDIT: 2 more things that I (possibly mistakenly) deduced: The following checks would be pretty useless:
- if (…renderCycle===2): this code might never be executed (see assumption 5)
- if (…env === “Server”): this code might never be executed (see assumption 4)