1.0.0 • Published 1 year ago
@krai-tech/web-api v1.0.0
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.
1.0.0
1 year ago