Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any plan to make components reactive? #136

Closed
suraciii opened this issue Aug 23, 2017 · 3 comments
Closed

Is there any plan to make components reactive? #136

suraciii opened this issue Aug 23, 2017 · 3 comments

Comments

@suraciii
Copy link
Contributor

I'm submitting a...


[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Support request => Please do not submit support request here

Current behavior

These components current are barely reactive, so some components won't work well if used by parent/root components which marked ChangeDetectionStrategy.OnPush, unless mark changes manually.

Expected behavior

Components work well even if they're under ChangeDetectionStrategy.OnPush scene.

Minimal reproduction of the problem with instructions

  1. Create a component with ChangeDetectionStrategy.OnPush
@Component({
  selector: 'app-root',
  changeDetection: ChangeDetectionStrategy.OnPush,
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
}
  1. Add <nz-popconfirm> to the component
  <nz-popconfirm [nzTitle]="'确定要删除吗?'" (nzOnConfirm)="confirm()"
    (nzOnCancel)="cancel()">
    <a nz-popconfirm>删除</a>
  </nz-popconfirm>
  1. Click the a element and there's no popup

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z

ng-zorro-antd version: X.Y.Z

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:


I've noticed that comment #74 (comment)

For everyone who uses OnPush mode, they must add ref.markForCheck() to every logic which should update components' data, or turn to use Default mode.

Use rxjs/Observable could solve this problem, But i don't know whether it will lead to more complex problems, I've not tested for ng-zorro yet.

But i think it would not break the current component structure - it is only need to change the middle layer data to observable, like the nzVisible property in NzPopconfirmComponent, the other Input properties will not be changes.

Anyway thanks for your nice work, i really like those components and theirs style.

@vthinkxie
Copy link
Member

vthinkxie commented Aug 23, 2017

Yes, onPush is not supported yet, and I can't make a promise when it will be supported at this moment.
The most important thing is ensuring all bugs to be fixed until 0.5.0 final version release.
It needs a lot of work to support onPush since that all components need to be tested, and some strategies need to be rewrite.

welcome pr for this, and thanks very much for your feedback.

@LinboLen
Copy link
Contributor

+1 for manual detectChanges, markForCheck

@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants