# j-Watcher

> This component executes the code defined in the <script type='text/js'></script> tag.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 31f1cf7cf34096c42e1ca2f7ec8685d43f06c1c1f06954e602153e5e04fead9e
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

This component executes the code defined in the `<script type="text/js"></script>` tag.

```html
<script type="text/js">

	// value {Object} a value bound according to the path
	// path {String} a path where the value was bonded
	// type {Number} binding type (0: init, 1: manually, 2: by input, 3: default value)
	// element {jQuery element} a current element
	// datasource {Object}
	// component {jComponent}

</script>
```

__Configuration__:

- `delay {Number}` a delay for evaluating code (default: `0`)
- __NEW__: `datasource {String}` a link to the datasource (it will be stored in `datasource` property)

__IMPORTANT__:

You need to use `<script type="text/js">` or `<script type="text/plain">`. Don't use the script element without `type` or with type `text|application/javascript` because the script will be evaluated by the browser automatically.

Use it with `<ui-component name="watcher">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="watcher" path="common.value">
	<script type="text/js">
		console.log('-->', value, path, type);
		element.html(value);
	</script>
</ui-component>

<script>
	var common = { value: 'init' };
	setInterval(function() {
		SET('common.value', new Date().format('HH:mm:ss'));
	}, 1000);
</script>
```
