https://github.com/writetome51/observable-service
Abstract Typescript/JavaScript class that acts as a middleman between the class that creates the observable and the class that subscribes to the observable
https://github.com/writetome51/observable-service
javascript observable typescript
Last synced: 5 months ago
JSON representation
Abstract Typescript/JavaScript class that acts as a middleman between the class that creates the observable and the class that subscribes to the observable
- Host: GitHub
- URL: https://github.com/writetome51/observable-service
- Owner: writetome51
- License: mit
- Created: 2018-12-26T19:32:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-02T23:13:22.000Z (about 5 years ago)
- Last Synced: 2025-01-02T07:26:12.814Z (about 1 year ago)
- Topics: javascript, observable, typescript
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ObservableService\
An abstract TypeScript/JavaScript class which acts as an abstraction layer between
the provider of an observable and the class that subscribes to that observable.
NOTE: This version of ObservableService is intended for use with [RxJS](https://rxjs-dev.firebaseapp.com/) 6.1.x
and up.
## Example
view example
```ts
// Create a subclass...
export class UsersObservableService extends ObservableService {
constructor(
// an object with method that returns observable:
userQueryService: { getObservable: () => Subscribable }
) {
super(userQueryService);
}
}
// Now another class calls .subscribe() to access the data...
export class UsersSubscriptionService {
users: User[];
subscription: Subscription;
constructor(usersObservable: UsersObservableService) {
this.subscription = usersObservable.subscribe(
(users) => this.users = users
);
}
}
```
## Constructor
```ts
constructor(
__observableProvider: { getObservable: () => Subscribable }
)
```
## Methods
```ts
subscribe(observer): Unsubscribable
```
## Installation
`npm i @writetome51/observable-service`
## Loading
```js
import { ObservableService } from '@writetome51/observable-service';
```
## License
[MIT](https://choosealicense.com/licenses/mit/)