forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:message,notification): add close event (NG-ZORRO#2952)
* feat(module:message, notification): add close event close NG-ZORRO#2458 * docs: fix Chinese doc not translated * fix: remove redundant declaration
- Loading branch information
Showing
15 changed files
with
165 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 4 | ||
title: | ||
zh-CN: 结束事件 | ||
en-US: Customize duration | ||
--- | ||
|
||
## zh-CN | ||
|
||
可通过订阅 `onClose` 事件在 message 关闭时做出某些操作。以上用例将依次打开三个 message。 | ||
|
||
## en-US | ||
|
||
You can subscribe to `onClose` event to make some operations. This case would open three messages in sequence. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Component } from '@angular/core'; | ||
import { NzMessageService } from 'ng-zorro-antd'; | ||
import { concatMap } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-message-close', | ||
template: ` | ||
<button nz-button [nzType]="'default'" (click)="startShowMessages()">Display a sequence of messages</button> | ||
`, | ||
styles : [] | ||
}) | ||
export class NzDemoMessageCloseComponent { | ||
constructor(private message: NzMessageService) { | ||
} | ||
|
||
startShowMessages(): void { | ||
this.message.loading('Action in progress', { nzDuration: 2500 }).onClose.pipe( | ||
concatMap(() => this.message.success('Loading finished', { nzDuration: 2500 }).onClose), | ||
concatMap(() => this.message.info('Loading finished is finished', { nzDuration: 2500 }).onClose) | ||
).subscribe(() => { | ||
console.log('All completed!'); | ||
}); | ||
} | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
import { Subject } from 'rxjs'; | ||
|
||
export type NzMessageType = 'success' | 'info' | 'warning' | 'error' | 'loading'; | ||
|
||
export interface NzMessageDataOptions { | ||
nzDuration?: number; | ||
nzAnimate?: boolean; | ||
nzPauseOnHover?: boolean; | ||
} | ||
|
||
// Message data for terminal users | ||
/** | ||
* Message data for terminal users. | ||
*/ | ||
export interface NzMessageData { | ||
// TODO: remove the literal parts as it's widened anyway | ||
type?: 'success' | 'info' | 'warning' | 'error' | 'loading' | string; | ||
type?: NzMessageType | string; | ||
content?: string; | ||
} | ||
|
||
// Filled version of NzMessageData (includes more private properties) | ||
/** | ||
* Filled version of NzMessageData (includes more private properties). | ||
*/ | ||
export interface NzMessageDataFilled extends NzMessageData { | ||
messageId: string; // Service-wide unique id, auto generated | ||
state?: 'enter' | 'leave'; | ||
messageId: string; | ||
createdAt: Date; | ||
|
||
options?: NzMessageDataOptions; | ||
createdAt: Date; // Auto created | ||
state?: 'enter' | 'leave'; | ||
onClose?: Subject<boolean>; | ||
} |
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
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
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
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
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
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
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
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