Web API for Angular creates injection tokens for working with native web APIs, simplifying their implementation, testing, and maintenance in Angular applications.
- 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.
npm i @krai-tech/web-api
# or
yarn i @krai-tech/web-api
import { Token_Name } from '@krai-tech/web-api/tokens';
-
WINDOW
— provides access to the globalwindow
object -
NAVIGATOR
— provides access to thewindow.navigator
object -
USER_AGENT
— provides access to thewindow.navigator.userAgent
string -
ANIMATION_FRAME
— sharedObservable
based onwindow.requestAnimationFrame
-
CRYPTO
— provides access to thewindow.crypto
object -
LOCATION
— provides access to thewindow.location
object -
LOCAL_STORAGE
— provides access to thewindow.localStorage
object -
SCREEN
— provides access to thewindow.screen
object -
SESSION_STORAGE
— provides access to thewindow.sessionStorage
object -
PAGE_VISIBILITY
— wrapper for the APIdocument.addEventListener('visibilityChange')
-
HISTORY
— provides access to thewindow.history
object
Yes please! See the contributing guidelines for details.
This project is licensed under the terms of the MIT license.