
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@ng-web-apis/permissions
Advanced tools
A library for comfortable use of Permissions API in Angular applications
This is a library to use Permissions API with Angular.
If you do not have @ng-web-apis/common:
npm i @ng-web-apis/common
Now install the package:
npm i @ng-web-apis/permissions
Import service in your component:
import { PermissionsService } from '@ng-web-apis/permissions';
...
constructor(private readonly permissions: PermissionsService) {}
Now, use the service to retrieve the state of the permission in question. Below is an example of checking the permission to use geolocation:
const geolocationStatus$ = this.permissions.state('geolocation');
geolocationStatus$.subscribe((geolocationStatus) => doSomething(geolocationStatus));
Note, that a call to the permissions.state()
returns an observable, which will emit new values in case the state for
the permission in question changes. If you need to get state just once and stop observing the permission, you can use
take(1)
RxJs operator:
geolocationStatus$.pipe(take(1)).subscribe((geolocationStatus) => doSomething(geolocationStatus));
The observable is cold, meaning if there are no active subscriptions, it doesn't track the status of the permission.
The library also provides a tokens to simplify working with Permissions API:
PERMISSIONS_SUPPORT
returns true
if user's browser supports
Permissions APIexport class Example {
constructor(@Inject(PERMISSIONS_SUPPORT) private readonly permissionsSupport: boolean) {}
}
![]() | ![]() | ![]() | ![]() |
---|---|---|---|
79+ | 46+ | 43+ | 16+ |
Other Web APIs for Angular by @ng-web-apis
FAQs
A library for comfortable use of Permissions API in Angular applications
The npm package @ng-web-apis/permissions receives a total of 1,626 weekly downloads. As such, @ng-web-apis/permissions popularity was classified as popular.
We found that @ng-web-apis/permissions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.