Core utilities for Angular applications - MessageBus, PlatformService, WINDOW token, and helper functions
npm install @rt-tools/coreCore utilities for Angular applications.
``bash`
npm install @rt-tools/coreor
pnpm add @rt-tools/core
`typescript
import { isNil } from '@rt-tools/core';
if (isNil(value)) {
// value is null or undefined
}
`
`typescript
import { MessageBus } from '@rt-tools/core';
const bus = new MessageBus<'USER_LOGGED_IN' | 'USER_LOGGED_OUT'>();
// Subscribe to events
bus.ofType('USER_LOGGED_IN').subscribe(event => {
console.log('User logged in');
});
// Emit events
bus.emit({ type: 'USER_LOGGED_IN' });
`
`typescript
import { PlatformService } from '@rt-tools/core';
@Component({...})
export class MyComponent {
private platform = inject(PlatformService);
ngOnInit() {
if (this.platform.isPlatformBrowser) {
// Browser-only code
}
}
}
`
`typescript
import { WINDOW } from '@rt-tools/core';
@Component({...})
export class MyComponent {
private window = inject(WINDOW);
scrollToTop() {
this.window.scrollTo(0, 0);
}
}
``
- Angular 21+
- RxJS 7.8+
Apache-2.0