LZ.setValue()
The LZ.setValue() function is the main function in Leeze.js used to set or change a bucket's value.
The function has the following signature:
setValue(bucketName, val, forceChange = false)
Where:
bucketName {string}is the name of the bucket to be set/updated.val {any}is the desired value.forceChange {boolean} (Default: false)represents whether or notlz-onchangeshould be forcefully called.
A simple example:
<p lz-reactive lz-bucket="myBucket"></p>
<script>
LZ.setValue("myBucket", "Hello, World!");
</script>
This code correctly updates the paragraph content. Note that if the paragraph had the lz-onchange attribute, the callback function wouldn't have been called because it is the first time we're changing the "myBucket" bucket.
You can force the callback execution by passing true to the forceChange parameter.