ngx-pagination icon indicating copy to clipboard operation
ngx-pagination copied to clipboard

PaginationService emits twice?

Open snakone opened this issue 6 years ago • 3 comments

=======

Angular version: 8.1.3+

ngx-pagination version: 4.1.0

Description of issue: Due to design, array and pagination controls arent on the same component so i used the PaginationService to comunicate beetween those. It's work but the 'change' Observable emits 2 values instead of 1

Steps to reproduce: It happens on the Stackblitz demo, here is a picture https://cdn1.imggmi.com/uploads/2019/8/19/3031425802b9428b27fe293e80405901-full.png

Expected result: Emit only 1 value

Actual result: Emits 2 values

snakone avatar Aug 19 '19 13:08 snakone

Hi,

Just looked into this and yes this is the case. The thing is, PaginationService is not part of the public API of this library so I would not necessarily regard this behaviour as a bug (even if it seems kind of strange to you).

If you explain you use-case a little then I may be able to advise an alternative approach which does not rely on an internal and undocumented API.

michaelbromley avatar Aug 20 '19 08:08 michaelbromley

I looked more into the code and i found the PaginationPipe emits the id when it's registered (the clone) and also when I set the currentPage with the Service. Is this the default behaviour?

thanks for your reply

snakone avatar Aug 20 '19 09:08 snakone

I looked more into the code and i found the PaginationPipe emits the id when it's registered (the clone) and also when I set the currentPage with the Service. Is this the default behaviour?

Yes, this is what I found too when I investigated. Either this is by design or is an opportunity for improved internal re-architecture. I am not sure which 🤷‍♂️ 😂

michaelbromley avatar Aug 20 '19 09:08 michaelbromley