# ember-data-route

> Ensure you clean up after your models. Any routes you deactivate will check the model to ensure it is not unsaved. If it is it will either rollback or remove the model from the store depending if has been previously persisted.

Latest version **0.2.0** (published 2015-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-data-route
pnpm add ember-data-route
yarn add ember-data-route
bun add ember-data-route
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-10-14 |
| First published | 2014-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 120 |
| Author | Brian Cardarella |
| Maintainers | bcardarella |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-data-route
- Repository: https://github.com/dockyard/ember-data-route
- Homepage: https://github.com/dockyard/ember-data-route#readme
- Issues: https://github.com/dockyard/ember-data-route/issues
- npm.io page: https://npm.io/package/ember-data-route

## Dependencies (1)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^5.1.3

## Recent versions

- 0.2.0 (latest) — 2015-10-14
- 0.1.0 — 2015-06-11
- 0.0.4 — 2015-03-09
- 0.0.3 — 2014-11-03
- 0.0.2 — 2014-08-28
- 0.0.1 — 2014-07-16

## README

# Ember Data Route

[![Build](https://travis-ci.org/dockyard/ember-data-route.svg?branch=master)](https://travis-ci.org/dockyard/ember-data-route)

## About ##

Ensure you clean up after your models.

Any routes you deactivate will check the `model` to ensure it is not
unsaved. If it is it will either rollback or remove the model from the
store depending if has been previously persisted.

## Install ##

```bash
npm install ember-data-route --save-dev
```

## Usage ##

Add the mixin to any route you want:

```js
import Ember from 'ember';
import DataRoute from 'ember-data-route';

export default Ember.Route.extend(DataRoute, {
  ...
});
```

### Transition Confirmation ###

By default when you transition out of the route the data model is
rolled-back/removed automatically after the router is deactivated.
However, you may want to detect if this is going to happen and alert the
user of changes that will be lost. Typically you could use
`window.confirm` to allow the user to decide to proceed or not. In the
route you are mixing into you can provide your own
`willTransitionConfirm` function to handle this. By default this
function returns `true` and is passed the `transition` object as an
argument for you to handle. One possible override could be:

```js
export default Ember.Route.extend(DataRouteMixin, {
  willTransitionConfirm: function() {
    return window.confirm("You have unsaved changes that will be lost. Do you want to continue?");
  }
});
```

## Authors ##

* [Brian Cardarella](http://twitter.com/bcardarella)

[We are very thankful for the many contributors](https://github.com/dockyard/ember-data-route/graphs/contributors)

## Versioning ##

This library follows [Semantic Versioning](http://semver.org)

## Want to help? ##

Please do! We are always looking to improve this gem. Please see our
[Contribution Guidelines](https://github.com/dockyard/ember-data-route/blob/master/CONTRIBUTING.md)
on how to properly submit issues and pull requests.

## Legal ##

[DockYard](http://dockyard.com/ember-consulting), Inc &copy; 2014

[@dockyard](http://twitter.com/dockyard)

[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)

---
_Source: https://npm.io/package/ember-data-route · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
