# j-VirtualWire

> This is a very special UI component that can move elements from element to another element according to the selector and the value of the path. Look to the example for understanding.

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

This is a very special UI component that can move elements from `element` to another `element` according to the selector and the value of the path. Look to the example for understanding.

- `selector {String}` a selector for wires (default: `.virtualwire`)
- `delay {Number}` a delay in milliseconds for movement of elements (default: `10`)
- `repeat {Number}` a repeat delay for obtaining of element (default: `50` ms)
- `max {Number}` a maximum count for repeating (default: `100`)

Use it with `<ui-component name="virtualwire">`. 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
<div class="b">Virtual Wire Container:</div>
<ui-component name="virtualwire" path="common.page"></ui-component>

<hr />

<!-- YOU CAN HIDE THE ELEMENTS BELOW BY ADDING "hidden" CLASS -->
<div class="virtualwire" data-if="users">
	<div>USERS</div>
</div>

<div class="virtualwire" data-if="products" data-in="products_in" data-out="products_out">
	<div>PRODUCTS</div>
</div>

<script>

	var common = {};

	setInterval(function() {
		switch (common.page) {
			case 'users':
				SET('common.page', 'products');
				break;
			case 'products':
				NULL('common.page');
				break;
			default:
				SET('common.page', 'users');
				break;
		}
	}, 2000);

	function products_out() {
		console.log('products_out');
	}

	function products_in() {
		console.log('products_in');
	}

</script>
```
