How to: Set Object Values Using Lodash

Overview

When using Unqork, you might want to create or change the values of an object. To do that, use the _.create and _.set Lodash functions.

TIP  To read more about the parameters of the _.create and _.set Lodash functions, visit: https://lodash.com/docs/4.17.15.

How This Example Works

In this example, you'll use the _.create and _.set Lodash functions to create and alter your object path and value. First, you'll create an object using the _.create function. Next, you'll use end-user End-users, also known as Express Users, are the individuals accessing an application through Express View. In most cases, end-users are the customers using the product. input to alter the key/value pair of your object using the _.set function to set the path, or key, and value of your created object. Then, your module outputs the new key/value pair to the end-user.

Here are the basic steps for this example:

1. Your Calculator component creates a new object.
2. The end-user enters their key and value to hardcode into the object.
3. The object's key/value pair is hardcoded with the end-user's input.
4. The new object values display to the end-user.

Here's how the comnfiguration looks in the Module Builder:

A static image displaying the set object values with Lodash use case in the UDesigner module builder.

Here’s how the configuration looks in Express View Express View is how your end-user views you application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View.:

A static image displaying the set object values with Lodash use case in Express View.

 

Resources