Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
chore: release version 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
darahayes committed Nov 18, 2019
1 parent 71eafd3 commit 85485d3
Show file tree
Hide file tree
Showing 14 changed files with 459 additions and 20 deletions.
16 changes: 16 additions & 0 deletions docs/ref-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ title: What is new in Offix
sidebar_label: Release notes
---

# 0.10.0

The `0.10.0` release builds upon the `0.9.0` release and adds two new packages. `offix-scheduler` and `offix-conflicts-client`

## offix-scheduler

`offix-scheduler` now holds the core functionalities of the Offix project. That includes queueing, scheduling, persistence and fulfilment of offline operations.

`offix-scheduler` can and will be used to create new clients in the future that are not based on Apollo Client. Clients we are investigating are URQL (see https://github.com/aerogear/offix/issues/235), Relay (see https://github.com/aerogear/offix/issues/236) and plain HTTP/REST. `offix-client` now uses `offix-scheduler` under the hood.

There have been no functional changes to `offix-client` and everything should remain the same.

## offix-conflicts-client

The `offix-conflicts-client` package contains all the interfaces and current implementations for client side pluggable conflict detection and resolution. Right now this package is used in to deliver the conflict capabilities in `offix-client` and it could also be used by package maintainers to implement conflict capabilities in new clients also. It is not important for application developers looking to use `offix-client`

# 0.9.0

The `0.9.0` release is a significant refactor of the internals of Offix and introduces a couple of breaking changes to the end user API.
Expand Down
4 changes: 2 additions & 2 deletions examples/conflicts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "conflict-examples",
"version": "0.9.0",
"version": "0.10.0",
"private": true,
"description": "",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"express": "^4.16.4",
"graphql": "0.13.2",
"graphql-tools": "^4.0.3",
"offix-conflicts-server": "0.9.0"
"offix-conflicts-server": "0.10.0"
},
"devDependencies": {
"@types/graphql": "^14.0.3",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"examples/*",
"packages/*"
],
"version": "0.9.0",
"version": "0.10.0",
"command": {
"publish": {
"exact": true
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-cache",
"version": "0.9.0",
"version": "0.10.0",
"description": "GraphQL Mutation and Subscription Helpers",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/offix-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-client",
"version": "0.9.0",
"version": "0.10.0",
"description": "Offix GraphQL Offline Client",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -48,10 +48,10 @@
"apollo-link-retry": "2.2.15",
"debug": "4.1.1",
"idb-localstorage": "0.2.0",
"offix-cache": "0.9.0",
"offix-conflicts-client": "0.9.0",
"offix-offline": "0.9.0",
"offix-scheduler": "0.9.0"
"offix-cache": "0.10.0",
"offix-conflicts-client": "0.10.0",
"offix-offline": "0.10.0",
"offix-scheduler": "0.10.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/offix-conflicts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-conflicts-client",
"version": "0.9.0",
"version": "0.10.0",
"description": "adds client side conflict detection and resolution",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand All @@ -17,7 +17,6 @@
"ts-node": "8.5.0",
"typescript": "3.7.2"
},
"dependencies": {},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-conflicts-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-conflicts-server",
"version": "0.9.0",
"version": "0.10.0",
"description": "Offix GraphQL server",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions packages/offix-offline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-offline",
"version": "0.9.0",
"version": "0.10.0",
"description": "Offix package that exposes network interfaces",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand All @@ -26,6 +26,5 @@
"ts-jest": "24.1.0",
"ts-node": "8.5.2",
"typescript": "3.7.2"
},
"dependencies": {}
}
}
6 changes: 3 additions & 3 deletions packages/offix-scheduler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-scheduler",
"version": "0.9.0",
"version": "0.10.0",
"description": "",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -33,8 +33,8 @@
},
"dependencies": {
"idb-localstorage": "^0.2.0",
"offix-cache": "^0.9.0",
"offix-offline": "^0.9.0"
"offix-cache": "0.10.0",
"offix-offline": "0.10.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-offix-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-offix-hooks",
"version": "0.9.0",
"version": "0.10.0",
"description": "Use offix-client in react hooks",
"keywords": [
"offix",
Expand Down Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@types/lodash": "4.14.147",
"lodash": "4.17.15",
"offix-client": "0.9.0"
"offix-client": "0.10.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0",
Expand Down
112 changes: 112 additions & 0 deletions website/versioned_docs/version-0.10.0/ref-offix-scheduler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
id: version-0.10.0-offix-scheduler-introduction
title: Offix Scheduler Introduction
sidebar_label: Introduction
original_id: offix-scheduler-introduction
---

Offix Scheduler is the core component that delivers the offline queueing and storage in packages such as `offix-client`. The scheduler can be used in an application directly to build offline workflows, or it can be as the foundation to build new packages and clients with offline functionality.

Unlike `offix-client` which provides many features out of the box, `offix-scheduler` provides a lower level set of core functionalities which can be used to build offline experiences.

* `NetworkStatus` interface for defining when an app is and is not offline.
* `Executor` interface for defining the operations/behaviour to be scheduled. Example: A HTTP request, sending a message, a GraphQL request.
* Offline queue mechanism where all operations are scheduled and fulfilled in order.
* `OfflineQueueListener` functions that are called at various stages in the queue lifecycle. Can be used to extend the queue with additional behaviour.
* Offline storage mechanism for persisting operations in the queue and restoring them after application restarts.

See [Offix-Client](./getting-started.md) for a fully featured implementation that uses the Offix Scheduler.


## Installation

Using [npm](https://www.npmjs.com/package/offix-scheduler):

```shell
npm install offix-scheduler
```

Or [yarn](https://yarnpkg.com/en/package/offix-scheduler):

```shell
yarn add offix-scheduler
```

## Getting Started Example

This example shows how `offix-scheduler` could be used to schedule HTTP Requests using the `fetch` API found in most browsers.

### Executor

An `Executor` is a class or an object with an `execute` method that will be called by the scheduler. This is the core operation/behaviour to be scheduled while offline. In this example we will define a `FetchExecutor` class that can make requests using `fetch`.

```js
class FetchExecutor {
// You could pass in some state and initialize it within the constructor
constructor() {}

// The execute function where the http request is made
// options is an object which can contain any properties
// you wish to pass in.
public async execute(options) {

// in this example options will have a url and a body
const { url, body } = options;

// make the request
const res = await fetch(url, {
method: "post",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body)
});

// return the result
return res.json();
}
}
```

The `execute` method defines the business logic to be scheduled. In this example, we're scheduling HTTP `POST` requests using the `fetch` API. `execute` accepts an `options` object which can contain any properties needed to perform the operation. In this case `execute` expects the options to have a `url` which is where we will send the request and a `body` which will be the body of the request.

This example is simplified as a realistic example would likely need to handle more options and also various error cases.

### Initialize the `OffixScheduler`

The example below shows how to initialize the `OffixScheduler` with the `Executor` we defined above.

```js
const offix = new OffixScheduler({
executor: new FetchExecutor()
});

await offix.init();
```

### Schedule an Operation

To schedule an operation, call `execute` on the scheduler and pass down any options needed by the `Executor`.

```js
try {
// if online the result is immediately returned
const result = await offix.execute({
url: "http://example.com/tasks",
body: {
title: "A New Task!",
description: "This was created by Offix Scheduler"
}
});
} catch (err) {
// check if an offline error occurred and wait for the result.
if (err.offline) {
const result = await err.watchOfflineChange();
}
}
```







0 comments on commit 85485d3

Please sign in to comment.