Created
June 22, 2024 02:08
-
-
Save JenHsuan/4f30630e4851e2f89bfcdad346a3808d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent implements AfterViewInit{ | |
protected undoConfigurationSubject = new BehaviorSubject<TopologyCommand | null>(null); | |
undoConfiguration$ = this.undoConfigurationSubject.asObservable(); | |
protected resetConfigurationSubject = new BehaviorSubject<boolean | null>(null); | |
resetConfiguration$ = this.resetConfigurationSubject.asObservable(); | |
.., | |
get isUndoButtonDisplayed(): boolean { | |
return this.commandStack.length > 0; | |
} | |
get undoButtonText() { | |
return `Undo (${this.commandStack.length})`; | |
} | |
protected onUndoButtonClicked() { | |
if (this.commandStack.length === 0) { | |
return; | |
} | |
this.undoConfigurationSubject.next(this.commandStack[0]); | |
} | |
protected onResetButtonClicked() { | |
const length = this.commandStack.length; | |
for (let i = 0; i < length; i++) { | |
this.commandStack.pop(); | |
} | |
this.resetConfigurationSubject.next(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment