@krai-tech/web-api
v1.0.0
Published
A set of common tokens for consuming Web API with Angular.
Downloads
70
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-api
Import
import { Token_Name } from '@krai-tech/web-api/tokens';
Tokens
WINDOW
— provides access to the globalwindow
objectNAVIGATOR
— provides access to thewindow.navigator
objectUSER_AGENT
— provides access to thewindow.navigator.userAgent
stringANIMATION_FRAME
— sharedObservable
based onwindow.requestAnimationFrame
CRYPTO
— provides access to thewindow.crypto
objectLOCATION
— provides access to thewindow.location
objectLOCAL_STORAGE
— provides access to thewindow.localStorage
objectSCREEN
— provides access to thewindow.screen
objectSESSION_STORAGE
— provides access to thewindow.sessionStorage
objectPAGE_VISIBILITY
— wrapper for the APIdocument.addEventListener('visibilityChange')
HISTORY
— provides access to thewindow.history
object
Contribution
Yes please! See the contributing guidelines for details.
Documentation
License
This project is licensed under the terms of the MIT license.