Browse Source

Version 0.5.0

master v0.5.0
Ezerous 4 years ago
parent
commit
1d0d9c121d
  1. 4
      package.json
  2. 17
      src/Breeze.js
  3. 4
      src/breezeStatus/breezeStatusReducer.js
  4. 1
      src/constants.js
  5. 4
      src/index.js
  6. 4
      src/ipfs/ipfsReducer.js
  7. 2
      src/ipfs/ipfsSaga.js
  8. 4
      src/orbit/orbitReducer.js
  9. 6
      src/orbit/orbitSaga.js
  10. 1824
      yarn.lock

4
package.json

@ -1,6 +1,6 @@
{
"name": "@ezerous/breeze",
"version": "0.4.0",
"version": "0.5.0",
"description": "A reactive data-store for OrbitDB.",
"license": "MIT",
"author": "Ezerous <ezerous@gmail.com>",
@ -8,7 +8,7 @@
"repository": "github:Ezerous/breeze",
"dependencies": {
"deepmerge": "~4.2.2",
"ipfs": "~0.52.0",
"ipfs": "~0.54.2",
"is-plain-object": "~5.0.0",
"orbit-db": "~0.26.0",
"orbit-db-identity-provider": "~0.3.1",

17
src/Breeze.js

@ -2,6 +2,7 @@ import { BREEZE_INITIALIZING } from "./breezeStatus/breezeActions"
import defaultOptions from "./misc/defaultOptions";
import merge from "./misc/mergeUtils"
import {addOrbitDB, removeOrbitDB, orbitInit} from "./orbit/orbitActions";
import {STATUS_INITIALIZED} from "./constants";
// Load as promise so that async Breeze initialization can still resolve
const isEnvReadyPromise = new Promise((resolve) => {
@ -37,8 +38,20 @@ class Breeze {
})
}
initOrbit(id) {
this.store.dispatch(orbitInit(this, id));
async initOrbit(id) {
const { store, orbit } = this;
store.dispatch(orbitInit(this, id));
return new Promise(resolve => {
const unsubscribe = store.subscribe(() => {
const status = store.getState().orbit.status;
if (status === STATUS_INITIALIZED) {
unsubscribe();
return resolve(orbit);
}
})
});
}
// dbInfo = {address, type} (where address can also be a name)

4
src/breezeStatus/breezeStatusReducer.js

@ -1,8 +1,8 @@
import { STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
import { STATUS_UNINITIALIZED, STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
import { BREEZE_INITIALIZING,BREEZE_INITIALIZED, BREEZE_FAILED } from "./breezeActions";
const initialState = {
status: STATUS_INITIALIZING
status: STATUS_UNINITIALIZED
}
const breezeStatusReducer = (state = initialState, action) => {

1
src/constants.js

@ -1,4 +1,5 @@
// Status
export const STATUS_UNINITIALIZED = 'uninitialized';
export const STATUS_INITIALIZING = 'initializing';
export const STATUS_INITIALIZED = 'initialized';
export const STATUS_FAILED = 'failed';

4
src/index.js

@ -7,6 +7,7 @@ import breezeStatusSaga from './breezeStatus/breezeStatusSaga';
import orbitSaga from "./orbit/orbitSaga";
import * as BreezeActions from './breezeStatus/breezeActions'
import * as IpfsActions from './ipfs/ipfsActions'
import * as OrbitActions from './orbit/orbitActions'
import * as breezeConstants from './constants'
@ -27,7 +28,8 @@ const breezeSagas = [
const breezeActions = {
breeze: BreezeActions,
orbit: OrbitActions
orbit: OrbitActions,
ipfs: IpfsActions
}
export {

4
src/ipfs/ipfsReducer.js

@ -1,8 +1,8 @@
import { IPFS_INITIALIZING , IPFS_INITIALIZED, IPFS_FAILED } from "./ipfsActions";
import { STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
import { STATUS_UNINITIALIZED, STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
const initialState = {
status: STATUS_INITIALIZING
status: STATUS_UNINITIALIZED
};
const ipfsReducer = (state = initialState, action) => {

2
src/ipfs/ipfsSaga.js

@ -15,7 +15,7 @@ export function * initializeIPFS (ipfsOptions) {
// Initialize IPFS
const ipfs = yield call(IPFS.create, ipfsOptions);
yield put({ type: IpfsActions.IPFS_INITIALIZED });
yield put({ type: IpfsActions.IPFS_INITIALIZED, ipfs });
return ipfs;
} catch (error) {

4
src/orbit/orbitReducer.js

@ -19,10 +19,10 @@ import {
DB_STATUS_REMOVED
} from "./orbitConstants";
import {STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
import { STATUS_UNINITIALIZED, STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants";
const initialState = {
status: STATUS_INITIALIZING,
status: STATUS_UNINITIALIZED,
databases: {}
};

6
src/orbit/orbitSaga.js

@ -133,6 +133,10 @@ function * removeDatabase({dbInfo}) {
databases.delete(address);
if(store){
const { eventChannel } = store;
if(eventChannel)
eventChannel.close();
yield call([store, store.close]);
yield put({ type: ORBIT_DB_REMOVED, address });
return;
@ -183,6 +187,8 @@ function createOrbitDatabaseChannel (database){
function * callListenForOrbitDatabaseEvent ({ database }) {
const orbitDatabaseChannel = yield call(createOrbitDatabaseChannel, database);
database.eventChannel = orbitDatabaseChannel;
yield put({type: ORBIT_DB_LISTEN, id: database.id});
try {

1824
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save