> For the complete documentation index, see [llms.txt](https://angularjs-store.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://angularjs-store.gitbook.io/docs/tutorials/destroy-a-hook.md).

# Destroy a hook

Whenever you add a hook in the store, it always returns a `HookLink` instance that represents the link between the hook and store. You can destroy this link anytime you want to stop the hook from listening on state changes.

{% hint style="danger" %}
The returned `HookLink` instance is only available inside the hook callback after the initial phase.
{% endhint %}

{% code title="your-controller.ts" %}

```typescript
import { CounterState, CounterStore } from 'counter-store';

function YourController($scope: ng.IScope, counterStore: CounterStore) {
  const hookLink = counterStore.hook('INCREMENT_COUNT', (state) => {
    $scope.count = state.count;
    
    if ($scope.count === 10) {
      hookLink.destroy();
    }
  });
}

angular
  .module('App', [])
  .controller('YourController', YourController);
```

{% endcode %}

Another method of `HookLink` is `destroyOn`. You can use this method if you want to destroy a hook automatically. The only requirement is a `scope` where `hook` should be bound. When a scope triggers a `$destroy` event, the hook also gets destroyed.

{% code title="your-controller.ts" %}

```typescript
import { CounterState, CounterStore } from 'counter-store';

function YourController($scope: ng.IScope, counterStore: CounterStore) {
  counterStore.hook('INCREMENT_COUNT', (state) => {
    $scope.count = state.count;
  }).destroyOn($scope);
}

angular
  .module('App', [])
  .controller('YourController', YourController);
```

{% endcode %}
