Skip to content

A set of common utils for consuming Web APIs with Angular

License

Notifications You must be signed in to change notification settings

i-magera/common

 
 

Repository files navigation

logo Common utils for Web APIs

Part of Web APIs for Angular

npm version npm bundle size Travis (.org) Coveralls github

A set of common utils for consuming Web APIs with Angular

Tokens

  • WINDOW — provides access to global window object
  • NAVIGATOR — provides access to window.navigator object
  • NETWORK_INFORMATION — provides access to window.navigator.connection object
  • USER_AGENT — provides access to window.navigator.userAgent string
  • PERFORMANCE — provides access to window.performance object
  • ANIMATION_FRAME — shared Observable based on window.requestAnimationFrame
  • CSS — provides access to window.CSS object or mock object if it's not available (i.e. in IE)
  • LOCATION — provides access to window.location object
  • LOCAL_STORAGE — provides access to window.localStorage object
  • SESSION_STORAGE — provides access to window.sessionStorage object
  • SPEECH_RECOGNITION — provides access to SpeechRecognition class or returns null if browser does not support it
  • SPEECH_SYNTHESIS — provides access to window.speechSynthesis object
  • PAGE_VISIBILITY — wrapper for document.addEventListener('visibilityChange') api

How to use

Just inject a token you need. You can also take a look at Stackblitz sample

What advantages do we get from abstract entities in our app?

  • It is easy to understand: you see all dependencies of your entity in its constructor
  • It is easy to test: you can just mock any of your dependencies to test
  • It is easy to reuse: your components and directives can be used in any context if it has dependencies that they need to be created
  • It is enviroment agnostic: you can start your app in SSR or other environments (see also @ng-web-apis/universal)

See also

Other Web APIs for Angular by @ng-web-apis

About

A set of common utils for consuming Web APIs with Angular

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 77.8%
  • JavaScript 22.2%