custom-module: clean & docs
This commit is contained in:
parent
6cc020c10d
commit
44b03941f9
3 changed files with 15 additions and 11 deletions
|
|
@ -99,6 +99,12 @@ Saves an object/array to a json file (path is relative to the custom module loca
|
|||
|
||||
----
|
||||
|
||||
#### `require(path)`
|
||||
|
||||
Load another javascript module. Returns the value of `module.exports` defined in this module. If `path` is a relative path, it will be resolved against its parent module's path. See [Managing Big Modules](../managing-big-modules)
|
||||
|
||||
----
|
||||
|
||||
#### Other javascript globals
|
||||
- `console`
|
||||
- `setTimeout`
|
||||
|
|
@ -107,3 +113,8 @@ Saves an object/array to a json file (path is relative to the custom module loca
|
|||
- `clearInterval`
|
||||
|
||||
----
|
||||
|
||||
|
||||
## Autoreload
|
||||
|
||||
Custom modules (including submodules loaded with `require()`) are reloaded automatically when they are modified. Upon reload, timers (`setTimeout` and `setInterval`) and event listeners (added to the `app` object) are reset.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
Custom modules don't let you use node's `require` function at runtime, but you can manage your sources in multiple files and bundle them into a single file before loading it in OSC.
|
||||
|
||||
The common pattern for this is using the [browserify](http://browserify.org/) library:
|
||||
Starting with `v1.6.0`, custom modules can load submodules with the `require()` function.
|
||||
|
||||
**1**. define some variable in `number.js`
|
||||
|
||||
|
|
@ -22,8 +20,3 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
**3**. bundle your sources into `custom-module.js`:
|
||||
|
||||
`browserify main.js -o custom-module.js --standalone module.exports`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue