Skip to content

Keep Key Command

Hawkmax edited this page Oct 10, 2025 · 4 revisions

Description

Conceptually RichJSON resolves commands, inheritance, etc. only once.
So if you want to resolve JSON a second time you would need a unsresolved copy of the according struct. But of course this would be very disapointing when using commands like #spawn, #twin or #ui, since these commands are creating something that is often used more than once. So of course we had our troubles with this behaviour but on the other side, resolving everything every time would not be an option, due to performance reasons.
You can image the rest of the story, right?

Keep Key Command was born

So we came up with a compromise, which included resolving Key Commands a second time, Member Commands however, can not be resolved a second time as the RichJSON command string gets overriten by the result. This can be achieved by using the following function:

/// @func rich_json_keep_key_command(_member)
/// @desc Includes the command into the struct of the corresponding key command.
///       Which makes the command resolveable more than once.
function rich_json_keep_key_command(_member) {

Example

function(_cryptkey, _add_to_cache, _root, _current, _command, _member, _address, _name) {
    rich_json_keep_key_command(_member); // _member has to be a struct
    // your implementation
    return rv;
}

Author’s Recommendation: next read Configuration

Clone this wiki locally