Question about flash scope and relocate in ColdBox
# box-products
a
Question about flash scope and relocate in ColdBox
An example (from the docs) is:
Copy code
flash.persistRC(include="name,email,address");
relocate('wizard.step2');
The default behaviour of flash scope is to inflate into the rc scope on the next request. (flash.inflateToRC setting)
In the above scenario I've always done it as
relocate(event='wizard.step2', persist="name,email,address")
Which approach is the recommended "box" way and why? Thanks :)
I think I'm going to switch to using
flash
because: • flash gives a bit more flexibility • flash can inflate to private scope - I often stick validation results in there so nice to separate rc (which can come from the client) vs prc (which is trusted) • relocate is probably doing too much (SRP) - but is convenient!
Would still like opinions though šŸ™‚
l
Flash scope is the preferred way as it is the central authority. The relocations are just shortcuts. So in reality both are ok. But flash has more features
šŸ‘ 1
a
Thanks - have switched to flash scope but always nice to know that I'm following best practice šŸ™‚
l
Also note that flash can be stored ultimately in many storages. Or you could build a custom storage