@opentiny/next-ng
快速开始
app.ts
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { NextClientService } from '@opentiny/next-ng';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.html',
styleUrl: './app.scss'
})
export class App implements OnInit, AfterViewInit {
protected title = 'ng-demo-next';
constructor(
private nextClientService: NextClientService,
) {}
async ngOnInit() {
const { sessionId } = await this.nextClientService.useNextClient({
clientInfo: { name: 'my-project', version: '1.0.0' },
proxyOptions: { url: 'https://xxx/sse', token: '' }
})
console.log('sessionId', sessionId)
}
ngAfterViewInit() {
this.nextClientService.connect()
}
}
my-page.ts
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { NextServerService } from '@opentiny/next-ng';
@Component({
selector: 'my-page',
templateUrl: './my-page.html'
})
export class MyPage implements OnInit, AfterViewInit {
constructor(private nextServerService: NextServerService) {}
ngOnInit() {
const { server } = this.nextServerService.useNextServer({
serverInfo: { name: 'company-list', version: '1.0.0' }
})
}
ngAfterViewInit() {
this.nextServerService.connect()
}
}