# j-HashChange

> The component captures all changes for #hashtag in the URL address. When change, it emits event hash. The component reacts to the real changes.

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

The component captures all changes for `#hashtag` in the URL address. When change, it emits event `hash`. The component reacts to the real changes.

- singleton

__Configuration__:

- `delay {Number}` a delay for emitting `hash` event (default: `0`)
- __NEW__: `middleware {String}` a middleware (separated by the comma) for initial emit of the `hash` event

__How to capture hash change?__

```js
// Global:
ON('hash', function(hash) {
	// @hash {String} - it can be "empty"
});

// Or in the Plugin declaration:
exports.on('hash', function(hash) {

});
```

Use it with `<ui-component name="hashchange">`. 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="hashchange"></ui-component>

<ui-bind path="currenthash" config="text"></ui-bind>

<script>

	setInterval(() => location.hash = GUID(10), 1000);

	ON('hash', function(hash) {
		SET('currenthash', hash);
	});

</script>
```
