@krai-tech/web-api
v1.0.0
Published
A set of common tokens for consuming Web API with Angular.
Downloads
52
Maintainers
Readme
Web API for Angular creates injection tokens for working with native web APIs, simplifying their implementation, testing, and maintenance in Angular applications.
Purpose
- Testability: Injection tokens allow replacing real web APIs with mocks during testing.
- SSR: During server-side rendering (SSR), some web APIs are unavailable. Injection tokens help adapt the code to work on both client and server.
Installation
npm i @krai-tech/web-api
# or
yarn i @krai-tech/web-apiImport
import { Token_Name } from '@krai-tech/web-api/tokens';Tokens
WINDOW— provides access to the globalwindowobjectNAVIGATOR— provides access to thewindow.navigatorobjectUSER_AGENT— provides access to thewindow.navigator.userAgentstringANIMATION_FRAME— sharedObservablebased onwindow.requestAnimationFrameCRYPTO— provides access to thewindow.cryptoobjectLOCATION— provides access to thewindow.locationobjectLOCAL_STORAGE— provides access to thewindow.localStorageobjectSCREEN— provides access to thewindow.screenobjectSESSION_STORAGE— provides access to thewindow.sessionStorageobjectPAGE_VISIBILITY— wrapper for the APIdocument.addEventListener('visibilityChange')HISTORY— provides access to thewindow.historyobject
Contribution
Yes please! See the contributing guidelines for details.
Documentation
License
This project is licensed under the terms of the MIT license.
