Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,37 @@ sandbox.run();

The sandbox module provides the following methods:

`run` - Runs the sandbox. A promise will be returned that will be resolved once the server is ready.
### `run`

`init` - Initializes sandbox configuration files. A promise will be returned that will be resolved once the files have been generated.
Runs the sandbox. A promise will be returned that will be resolved once the server is ready.

You can provide a function option `getDefaultInitInfo` to modify the init info for a component as follows:

```js
const sandbox = require('@adobe/reactor-sandbox');
const getDefaultInitInfo = ({ info, type, name }) => {
if (type === 'actions') {
info.extensionSettings = {
myrequiredsetting: 'myvalue'
};
}
return info;
};

sandbox.run({ getDefaultInitInfo });
```

In this example the extensionSettings are defaulted to a different value. This may be useful if some of your components use required values from the extensionSettings to render. In the view sandbox `getDefaultInitInfo` will be called whenever a component loads for the first time, or when you click reset in the init tab. `getDefaultInitInfo` is called with the following options:

- `info` - The default init info as generated by reactor-sandbox.
- `type` - The component type. (One of "configuration", "events", "conditions", "actions", "dataElements")
- `name` - The name of the component as specified in extension.json. (For "configuration" types this is null.)

The return value will be used as the default initInfo when initializing your components.

### `init`

Initializes sandbox configuration files. A promise will be returned that will be resolved once the files have been generated.

## Contributing

Expand Down
Loading