Skip to content

Commit 1e40a76

Browse files
Update docs
1 parent 38adf39 commit 1e40a76

File tree

4 files changed

+56
-49
lines changed

4 files changed

+56
-49
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ cache:
1010
- node_modules
1111

1212
env:
13-
- EMBER_TRY_SCENARIO=default
13+
# - EMBER_TRY_SCENARIO=default
1414
- EMBER_TRY_SCENARIO=ember-release
15-
- EMBER_TRY_SCENARIO=ember-beta
16-
- EMBER_TRY_SCENARIO=ember-canary
15+
# - EMBER_TRY_SCENARIO=ember-beta
16+
# - EMBER_TRY_SCENARIO=ember-canary
1717

1818
matrix:
1919
fast_finish: true

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
- The `notify` property is no longer injected into routes and controllers by default. You should now
66
use `notify: Ember.inject.service()`
7+
- The `Notify` helper exported from the `ember-notify` package can no longer be used to send messages -
8+
you need to use the service
79
- The property names have changed from `message` and `raw` to `text` and `html`
8-
- The `Notify.*` helper methods (`info`, `success`, `warning`, `alert` and `error`) no longer return
10+
- The `info`, `success`, `warning`, `alert` and `error` methods no longer return
911
a Promise, they return a `Message` instance
1012

1113

README.md

+31-23
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ The CSS animations are inspired by CSS from [alertify.js](http://fabien-d.github
1212

1313
## Usage
1414

15-
1. Add `{{ember-notify}}` to one of your templates, usually in `application.hbs`.
16-
2. Use `this.notify` in routes or controllers to display messages:
15+
1. Add `{{ember-notify}}` to one of your templates, usually in `application.hbs`
16+
2. Inject the `notify` service
17+
3. Display messages using the `info`, `success`, `warning`, `alert` and `error` methods
18+
19+
### Examples
1720

1821
```js
19-
this.notify.info('Hello there!');
20-
this.notify.alert('This is an alert.');
21-
this.notify.success('It worked.');
22-
this.notify.warning('Hmmn, that didn\'t work out.');
23-
```
24-
25-
If you're not in a route or a controller you can use the `Notify` helper:
26-
27-
```js
28-
import Notify from 'ember-notify';
29-
Notify.info('Peace.');
22+
import {
23+
Component,
24+
inject
25+
} from 'ember';
26+
export default Component.extend({
27+
notify: inject.service('notify'),
28+
actions: {
29+
sayHello() {
30+
this.get('notify').info('Hello there!');
31+
}
32+
}
33+
});
3034
```
3135

3236
By default the notifications close after 2.5 seconds, although you can control this in your template:
@@ -38,40 +42,44 @@ By default the notifications close after 2.5 seconds, although you can control t
3842
Or you can control when each message is closed:
3943

4044
```js
41-
var message = Notify.alert('You can control how long it\'s displayed', {
45+
var notify = this.get('notify');
46+
var message = notify.alert('You can control how long it\'s displayed', {
4247
closeAfter: 10000 // or set to null to disable auto-hiding
4348
});
44-
message.set('visible', false); // and you can hide messages programatically.
49+
```
50+
51+
...and you can hide messages programatically:
52+
53+
```js
54+
message.set('visible', false);
4555
```
4656

4757
You can specify raw HTML:
4858

4959
```js
50-
Notify.info({html: '<div class="my-div">Hooray!</div>'});
60+
notify.info({html: '<div class="my-div">Hooray!</div>'});
5161
```
5262

5363
Rounded corners, if that's your thing:
5464

5565
```js
56-
Notify.alert('This one\'s got rounded corners.', {
66+
notify.alert('This one\'s got rounded corners.', {
5767
radius: true
5868
});
5969
```
6070

6171
### Multiple Containers
6272

6373
If you want to have separate notifications and control where they're inserted into the DOM you can
64-
have multiple `{{ember-notify}}` components, but only one of them can be accessed using the `Notify` helper. The others you will need to provide a `source` property.
65-
66-
Secondary containers should be used as follows:
74+
have multiple `{{ember-notify}}` components, but only one of them can be accessed using the injected service.
75+
The others you will need to provide a `source` property, so secondary containers should be used as follows:
6776

6877
```hbs
6978
{{ember-notify source=someProperty}}
7079
```
7180

7281
```js
73-
// in your controller
74-
export default Ember.Controller.extend({
82+
export default Ember.Component.extend({
7583
someProperty: Notify.property(), // or this.set('someProperty', Notify.create())
7684
actions: {
7785
clicked: function() {
@@ -83,7 +91,7 @@ export default Ember.Controller.extend({
8391

8492
## Installation
8593

86-
This module is an ember-cli addon, so all you need to do is:
94+
This module is an ember-cli addon, so installation is easy as pie.
8795

8896
```sh
8997
npm install ember-notify --save-dev

config/ember-try.js

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1+
/* jshint node:true */
12
module.exports = {
23
scenarios: [
3-
//{
4-
// name: 'default',
5-
// dependencies: { }
6-
//},
74
{
85
name: 'ember-release',
96
dependencies: {
@@ -13,23 +10,23 @@ module.exports = {
1310
'ember': 'release'
1411
}
1512
},
16-
//{
17-
// name: 'ember-beta',
18-
// dependencies: {
19-
// 'ember': 'components/ember#beta'
20-
// },
21-
// resolutions: {
22-
// 'ember': 'beta'
23-
// }
24-
//},
25-
//{
26-
// name: 'ember-canary',
27-
// dependencies: {
28-
// 'ember': 'components/ember#canary'
29-
// },
30-
// resolutions: {
31-
// 'ember': 'canary'
32-
// }
33-
//}
13+
{
14+
name: 'ember-beta',
15+
dependencies: {
16+
'ember': 'components/ember#beta'
17+
},
18+
resolutions: {
19+
'ember': 'beta'
20+
}
21+
},
22+
{
23+
name: 'ember-canary',
24+
dependencies: {
25+
'ember': 'components/ember#canary'
26+
},
27+
resolutions: {
28+
'ember': 'canary'
29+
}
30+
}
3431
]
3532
};

0 commit comments

Comments
 (0)