Skip to content
This repository was archived by the owner on Sep 18, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

193 changes: 0 additions & 193 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and publish crudodb

on:
push:
branches: [ master ]
branches: [master]
jobs:
release:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
documentation/
dist/
node_modules/
coverage/

package-lock.json
yarn.lock
Expand Down
9 changes: 6 additions & 3 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/npm", {
"pkgRoot": "dist/src"
}],
[
"@semantic-release/npm",
{
"pkgRoot": "dist/src"
}
],
"@semantic-release/github"
]
}
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,6 @@ There are 3 flags to mark an item in indexeddb for processing.
+ U
+ D


## Recommendations

### Angular

```typescript
@Injectable({providedIn: 'root'})
export class StoreAccessService {

public instance$ = fromPromise(CrudoDb.setup)
.pipe(shareReplay(1));

}

@Injectable({providedIn: 'root'})
export class DaoService {

private key$ = this.storeAccess.instance$.pipe(
switchMap((instance) => instance.registerSchema({schema})),
shareReplay(1)
);

private handle$ = combineLatest([this.key$, this.storeAccess.instance$]).pipe(shareReplay(1));

constructor(private storeAccess: StoreAccessService) {}

public create(item: Dao): Observable<Dao> {
return this.handle$.pipe(
switchMap(([key, instance]) => instance.create(key, item))
);
}
}

```

### React (Hooks API)

```typescript jsx

// TODO: write hook(context) for it


```
see [documentation](docs) for angular and react recommendations.
43 changes: 43 additions & 0 deletions docs/angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Angular (rxjs)

recommendation for angular is to use shared root service, which setup the instance.

all consuming services need a schemaKey. To work smooth with it, cache it in a property and optional combine it with the instance from root service.

In all following usages, you have to pipe `handle$` to the matching method

```typescript
import {Injectable} from '@angular/core';
import {combineLatest, Observable} from "rxjs";
import {map, shareReplay, switchMap, tap} from "rxjs/operators";
import {fromPromise} from "rxjs/internal-compatibility";
import {CrudoDb} from "crudodb";

@Injectable({providedIn: 'root'})
export class StoreAccessService {

public instance$ = fromPromise(CrudoDb.setup)
.pipe(shareReplay(1));

}

@Injectable({providedIn: 'root'})
export class DaoService {

private key$ = this.storeAccess.instance$.pipe(
switchMap((instance) => instance.registerSchema({schema})),
shareReplay(1)
);

private handle$ = combineLatest([this.key$, this.storeAccess.instance$]).pipe(shareReplay(1));

constructor(private storeAccess: StoreAccessService) {}

public create(item: Dao): Observable<Dao> {
return this.handle$.pipe(
switchMap(([key, instance]) => instance.create(key, item))
);
}
}

```
3 changes: 0 additions & 3 deletions docs/api.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/index.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
React usage (hooks api)
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

module.exports = {
preset: 'jest-preset-typescript',
setupFiles: ['fake-indexeddb/auto']
setupFiles: ['fake-indexeddb/auto'],
coveragePathIgnorePatterns: ['/node_modules/', '/spec/']
};
25 changes: 21 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"format:prettier": "prettier --config .prettierrc --write",
"format:prettier:all": "yarn format:prettier \"**/*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|html)\"",
"semantic-release": "semantic-release"
"format:prettier:all": "yarn format:prettier \"**/*.+ts\"",
"semantic-release": "semantic-release",
"lint:es:fix": "yarn eslint --fix"
},
"repository": {
"type": "git",
Expand All @@ -32,21 +33,37 @@
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/node": "^14.11.5",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.4.0",
"babel-jest": "^26.5.2",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-ban": "^1.5.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-typescript": "^0.14.0",
"eslint-plugin-unused-imports": "^1.0.0",
"fake-indexeddb": "^3.0.0",
"husky": "^4.3.0",
"jest": "^26.5.2",
"jest-preset-typescript": "^1.2.0",
"lint-staged": "^10.5.0",
"prettier": "^2.1.2",
"semantic-release": "^17.2.1",
"ts-jest": "^26.4.1",
"tslint": "^6.0.0",
"tslint-config-airbnb": "^5.11.2",
"typescript": "^4.0.3",
"semantic-release": "^17.2.1"
"typescript": "^4.0.3"
},
"lint-staged": {
"*.+(js|ts)": [
"yarn format:prettier",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
Loading