Skip to content

Commit ed41433

Browse files
committed
Wrap the README to 80 columns
1 parent df075d2 commit ed41433

File tree

1 file changed

+47
-19
lines changed

1 file changed

+47
-19
lines changed

README.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
# Ember-cli-adapter-pattern [![Build Status](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern.svg?branch=master)](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern)
22

3-
An [Ember CLI](https://ember-cli.com/) addon to standardise a common adapter pattern.
3+
An [Ember CLI](https://ember-cli.com/) addon to standardise a common adapter
4+
pattern.
45

5-
The adapter pattern helps to provide a common interface from which two incompatible interface may work together. For example you may wish to include in your applications the ability to authenticate users through a variety of social platforms (i.e. Facebook and Twitter). Each platform defines its own API which to interface with it's servers. Using the adapter pattern you can separate the logic of both APIs into their own adapter objects, using a common interface to work with both.
6+
The adapter pattern helps to provide a common interface from which two
7+
incompatible interface may work together. For example you may wish to include
8+
in your applications the ability to authenticate users through a variety of
9+
social platforms (i.e. Facebook and Twitter). Each platform defines its own API
10+
which to interface with it's servers. Using the adapter pattern you can
11+
separate the logic of both APIs into their own adapter objects, using a common
12+
interface to work with both.
613

7-
This addon implements a common adapter pattern that can be included in any ember object allowing it to act as a proxy between the application and any external interface.
14+
This addon implements a common adapter pattern that can be included in any
15+
ember object allowing it to act as a proxy between the application and any
16+
external interface.
817

918
## Installation
1019

@@ -15,13 +24,16 @@ ember install ember-cli-adapter-pattern
1524

1625
## Usage
1726

18-
This addon implements a mixin that should be included in any object you wish to act as the interface between your application and any external platform or API.
27+
This addon implements a mixin that should be included in any object you wish to
28+
act as the interface between your application and any external platform or API.
1929

2030
### Adaptable Mixin
2131

22-
In order to implement the adapter pattern, it is recommended you include the `Adaptable` mixin into an ember object that will act as a singleton, i.e. a service.
32+
In order to implement the adapter pattern, it is recommended you include the
33+
`Adaptable` mixin into an ember object that will act as a singleton, i.e. a
34+
service.
2335

24-
##### <a name="adaptable-example"></a>Example:
36+
##### Adaptable Example
2537

2638
```JavaScript
2739
// app/services/social.js
@@ -32,7 +44,7 @@ import proxyToAdapter from 'ember-cli-adapter-pattern/utils/proxy-to-adapter';
3244
export default Ember.Service.extend(Adaptable, {
3345
login: proxyToAdapter('login'), // Provides a safe method to proxy your API to each adapter.
3446

35-
/*
47+
/**
3648
* There are potentially many ways
3749
* to activate adapters, but it is
3850
* imperative that somewhere the
@@ -48,7 +60,7 @@ export default Ember.Service.extend(Adaptable, {
4860
this.activateAdapters(adapters); // This is important and activates configured adapters.
4961
}),
5062

51-
/*
63+
/**
5264
* This is the only method that you
5365
* are required to write and defines
5466
* how you look up your adapters. It
@@ -67,13 +79,16 @@ export default Ember.Service.extend(Adaptable, {
6779
});
6880
```
6981

70-
This creates a service that will act as the common API for each of your adapters. Here you can see I have defined a single common API method named `login`.
82+
This creates a service that will act as the common API for each of your
83+
adapters. Here you can see I have defined a single common API method named
84+
`login`.
7185

7286
### Making API Calls
7387

74-
To make calls to your API you must inject the `Adaptable` object into another ember object (i.e. a controller) and invoke it as normal.
88+
To make calls to your API you must inject the `Adaptable` object into another
89+
ember object (i.e. a controller) and invoke it as normal.
7590

76-
##### <a name="all-adapters-example"></a>Example:
91+
##### All Adapters Example
7792

7893
```JavaScript
7994
// app/controller/application.js
@@ -90,9 +105,13 @@ export default Ember.Controller.extend({
90105
});
91106
```
92107

93-
The action defined in the controller will call the `login` method on the `social` service. This will in turn forward the invocation on to each of the adapters. Of course in this example it would make little sense to login with more than one platform at the same time. If you wish to call only one adapter then you must pass in it's name to the API call.
108+
The action defined in the controller will call the `login` method on the
109+
`social` service. This will in turn forward the invocation on to each of the
110+
adapters. Of course in this example it would make little sense to login with
111+
more than one platform at the same time. If you wish to call only one adapter
112+
then you must pass in it's name to the API call.
94113

95-
##### <a name="single-adapter-example"></a>Example:
114+
##### Single Adapter Example
96115

97116
```JavaScript
98117
// app/controller/application.js
@@ -111,13 +130,19 @@ export default Ember.Controller.extend({
111130

112131
This will only make the API call to the 'Facebook' adapter.
113132

114-
Each API call will be wrapped within a promise that resolves with the returned result of the adapter mapped to the adapter name.
133+
Each API call will be wrapped within a promise that resolves with the returned
134+
result of the adapter mapped to the adapter name.
115135

116136
### ProxyToAdapter Utility
117137

118-
The `proxyToAdapter` utility method simply forwards calls made to each of your API methods to all defined adapters, or just a single adapter if specified. It is recommended you use `proxyToAdapter` because it implements guard statements to prevent the application from throwing errors.
138+
The `proxyToAdapter` utility method simply forwards calls made to each of your
139+
API methods to all defined adapters, or just a single adapter if specified. It
140+
is recommended you use `proxyToAdapter` because it implements guard statements
141+
to prevent the application from throwing errors.
119142

120-
If however you need to extend the functionality of your API methods then somewhere in its implementation it needs to call the `invoke` method defined within the `Adaptable` mixin.
143+
If however you need to extend the functionality of your API methods then
144+
somewhere in its implementation it needs to call the `invoke` method defined
145+
within the `Adaptable` mixin.
121146

122147
```JavaScript
123148
// app/services/social.js
@@ -132,7 +157,8 @@ export default Ember.Service.extend(Adaptable, {
132157
});
133158
```
134159

135-
Here we are passing the name of the API call as the first argument to `invoke` followed by the arguments that were passed into the API call.
160+
Here we are passing the name of the API call as the first argument to `invoke`
161+
followed by the arguments that were passed into the API call.
136162

137163
## Development
138164

@@ -149,12 +175,14 @@ Here we are passing the name of the API call as the first argument to `invoke` f
149175

150176
### Running Tests
151177

152-
* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)
178+
* `npm test` (Runs `ember try:each` to test your addon against multiple Ember
179+
versions)
153180
* `ember test`
154181
* `ember test --server`
155182

156183
### Building
157184

158185
* `ember build`
159186

160-
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
187+
For more information on using ember-cli, visit
188+
[https://ember-cli.com/](https://ember-cli.com/).

0 commit comments

Comments
 (0)