Skip to content

Commit 957d4b6

Browse files
authored
Merge pull request #16 from Exilz/3.0
v3 | The plugin is now called APIpeline and works on browser / node / web 🚀
2 parents 4603f41 + 5081733 commit 957d4b6

File tree

26 files changed

+608
-303
lines changed

26 files changed

+608
-303
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
22
*.log
3-
3+
demos/web/.next
44
yarn.lock
5+
demos/web/package-lock.json

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
demo/
1+
demos/

README.md

Lines changed: 101 additions & 52 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

demo/App.js renamed to demos/react-native/App.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React, { Component, PropTypes } from 'react';
2-
import { View, Text, TouchableOpacity, ScrollView, StyleSheet } from 'react-native';
3-
import OfflineFirstAPI from 'react-native-offline-api';
4-
5-
const NativeModules = require('NativeModules');
1+
import React, { Component } from 'react';
2+
import { View, Text, TouchableOpacity, ScrollView, StyleSheet, AsyncStorage } from 'react-native';
3+
import APIpeline from 'apipeline';
64

75
const API_OPTIONS = {
6+
fetchMethod: fetch, // use react native's fetch
87
domains: { default: 'https://icanhazdadjoke.com' },
98
prefixes: { default: '' },
109
middlewares: [setHeadersMiddleware],
@@ -25,7 +24,7 @@ const API_SERVICES = {
2524
}
2625
};
2726

28-
const api = new OfflineFirstAPI(API_OPTIONS, API_SERVICES);
27+
const api = new APIpeline(API_OPTIONS, API_SERVICES, AsyncStorage);
2928

3029
async function setHeadersMiddleware () {
3130
// This doesn't need a middleware, it's just an example
@@ -43,9 +42,6 @@ export default class Demo extends Component {
4342
}
4443

4544
async _fetchRandomJoke () {
46-
// api.get('random', { disableCache: true });
47-
// return;
48-
// api.get('random', { disableCache: true });
4945
try {
5046
this.setState({ randomJokeStatus: 1, searchJokeStatus: 0, fetchStart: Date.now() });
5147
const req = await api.get('random');
@@ -95,7 +91,7 @@ export default class Demo extends Component {
9591
get description () {
9692
return (
9793
<ScrollView style={styles.descriptionContainer}>
98-
<Text style={styles.desc}>This demo showcases a very basic usage of the plugin. It uses the default cache driver (AsyncStorage).</Text>
94+
<Text style={styles.desc}>This demo showcases a very basic usage of the plugin. It uses react native's default cache driver (AsyncStorage).</Text>
9995
<Text style={styles.desc}>Two endpoints are registered as services (random & search). Both are using the GET method.</Text>
10096
<Text style={styles.desc}>You can see how fast the cache resolution is once your request has already been fired and when its cached data is fresh...</Text>
10197
<Text style={styles.desc}>Restart this application with your phone in offline mode to see how easy it is to make your app offline-first !</Text>
@@ -158,7 +154,6 @@ export default class Demo extends Component {
158154
<Text>Looking for dad jokes...</Text>
159155
);
160156
} else if (searchJokeStatus === 2 && searchedJokes ) {
161-
console.log('SEARCHED JOKES', searchedJokes)
162157
content = searchedJokes.map((result, index) => {
163158
const { id, joke, timestamp } = result;
164159
return (
@@ -185,7 +180,7 @@ export default class Demo extends Component {
185180
render () {
186181
return (
187182
<View style={styles.container}>
188-
<Text style={styles.title}>react-native-offline-api</Text>
183+
<Text style={styles.title}>APIpeline</Text>
189184
{ this.description }
190185
{ this.btns }
191186
{ this.randomJoke }

demos/react-native/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# react-native demo
2+
3+
This demo uses [expo](https://expo.io/). Check out their documentation to try out the plugin.

demo/app.json renamed to demos/react-native/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"expo": {
3-
"name": "react-native-offline-api demo",
4-
"description": "Basic demonstration of react-native-offline-api features",
5-
"slug": "react-native-offline-api-demo",
3+
"name": "apipeline demo",
4+
"description": "Basic demonstration of APIpeline features",
5+
"slug": "apipeline-demo",
66
"privacy": "public",
77
"sdkVersion": "25.0.0",
88
"platforms": ["ios", "android"],
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)