Skip to content

Commit c5557fc

Browse files
authored
Merge pull request #224 from dhilt/1.9.0-release
v1.9.0 release
2 parents 9bb3288 + 736036c commit c5557fc

30 files changed

+268
-105
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ Below is the list of invocable methods of the Adapter API with description and l
175175

176176
|Name|Parameters|Description|
177177
|:--|:----|:----------|
178-
|[reload](https://dhilt.github.io/ngx-ui-scroll/#/adapter#reload)|(startIndex?: number)|Resets the items buffer, resets the viewport params and starts fetching items from "startIndex" (if set). |
178+
|[relax](https://dhilt.github.io/ngx-ui-scroll/#/adapter#relax)|(callback?: Function)|Resolves asynchronously when there are no pending processes. If the _callback_ is set, it will be executed right before resolving. Basically, it needs to protect with the _relax_ every piece of the App logic, that might be sensitive to the uiScroll internal processes, to avoid interference and race conditions. |
179+
|[reload](https://dhilt.github.io/ngx-ui-scroll/#/adapter#reload)|(startIndex?: number)|Resets the items buffer, resets the viewport params and starts fetching items from _startIndex_ (if set). |
179180
|[reset](https://dhilt.github.io/ngx-ui-scroll/#/adapter#reset)|(datasource?: IDatasource)|Performs hard reset of the uiScroll internal state by re-instantiating all its entities (instead of reusing them when _reload_). If _datasource_ argument is passed, it will be treated as new Datasource. All props of the _datasource_ are optional and the result Datasource will be a combination (merge) of the original one and the one passed as an argument. |
180181
|[append](https://dhilt.github.io/ngx-ui-scroll/#/adapter#append-prepend)|(options: {<br>&nbsp;&nbsp;items:&nbsp;any[],<br>&nbsp;&nbsp;eof?:&nbsp;boolean<br>}) <br><br> (items:&nbsp;any&nbsp;&vert;&nbsp;any[], eof?:&nbsp;boolean) &#42;<br><sub>&#42; old signature, deprecated</sub>|Adds items to the end of the uiScroll dataset. If eof parameter is not set, items will be added and rendered immediately, they will be placed right after the last item in the uiScroll buffer. If eof parameter is set to true, items will be added and rendered only if the end of the dataset is reached; otherwise, these items will be virtualized. See also [bof/eof](https://dhilt.github.io/ngx-ui-scroll/#/adapter#bof-eof) demo. |
181182
|[prepend](https://dhilt.github.io/ngx-ui-scroll/#/adapter#append-prepend)|(options: {<br>&nbsp;&nbsp;items:&nbsp;any[],<br>&nbsp;&nbsp;bof?:&nbsp;boolean<br>}) <br><br> (items:&nbsp;any&nbsp;&vert;&nbsp;any[], bof?:&nbsp;boolean) &#42;<br><sub>&#42; old signature, deprecated</sub>|Adds items to the beginning of the uiScroll dataset. If bof parameter is not set, items will be added and rendered immediately, they will be placed right before the first item in the uiScroll buffer. If bof parameter is set to true, items will be added and rendered only if the beginning of the dataset is reached; otherwise, these items will be virtualized. See also [bof/eof](https://dhilt.github.io/ngx-ui-scroll/#/adapter#bof-eof) demo. |
@@ -186,7 +187,7 @@ Below is the list of invocable methods of the Adapter API with description and l
186187

187188
Along with the documented API there are some undocumented features that can be treated as experimental. They are not tested enough and might change over time. Some of them can be found on the [experimental tab](https://dhilt.github.io/ngx-ui-scroll/#/experimental) of the demo app.
188189

189-
All of the Adapter methods return Promise resolving at the moment when the scroller terminates its internal processes triggered by the invocation of the Adapter method. It might be quite important to run some logic after the Adapter finished its job. Also, it is recommended to protect the first Adapter call by the [relax method](https://dhilt.github.io/ngx-ui-scroll/#/experimental#adapter-relax). Below is an example of how an explicit sequence of the Adapter methods can be implemented:
190+
All of the Adapter methods return Promise resolving at the moment when the scroller terminates its internal processes triggered by the invocation of correspondent Adapter method. It is called [Adapter Return API](https://dhilt.github.io/ngx-ui-scroll/#/adapter#return-value). This promise has exactly the same nature as the promise of the [relax method](https://dhilt.github.io/ngx-ui-scroll/#/experimental#adapter-relax). Both "Relax" and "Return API" are the instruments of the App-Scroller processes normalization. It might be quite important to run some logic after the Scroller finishes its job and relaxes. Below is an example of how an explicit sequence of the Adapter methods can be safely implemented:
190191

191192
```js
192193
const { adapter } = this.datasource;

demo/app/app.module.ts

Lines changed: 8 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,12 @@ import { SettingsComponent } from './samples/settings.component';
1717
import { AdapterComponent } from './samples/adapter.component';
1818
import { DatasourceComponent } from './samples/datasource.component';
1919
import { ExperimentalComponent } from './samples/experimental.component';
20-
21-
import { DemoBasicComponent } from './samples/common/basic.component';
22-
import { DemoBufferSizeComponent } from './samples/common/buffer-size.component';
23-
import { DemoPaddingComponent } from './samples/common/padding.component';
24-
import { DemoItemSizeComponent } from './samples/common/item-size.component';
25-
import { DemoStartIndexComponent } from './samples/common/start-index.component';
26-
import { DemoMinMaxIndexesComponent } from './samples/common/min-max-indexes.component';
27-
import { DemoInfiniteComponent } from './samples/common/infinite.component';
28-
import { DemoHorizontalComponent } from './samples/common/horizontal.component';
29-
import { DemoDifferentHeightsComponent } from './samples/common/different-heights.component';
30-
import { DemoWindowViewportComponent } from './samples/common/window-viewport.component';
31-
import { DemoAdapterReturnValueComponent } from './samples/adapter/adapter-return-value.component';
32-
import { DemoResetComponent } from './samples/adapter/reset.component';
33-
import { DemoReloadComponent } from './samples/adapter/reload.component';
34-
import { DemoIsLoadingComponent } from './samples/adapter/is-loading.component';
35-
import { DemoItemsCountComponent } from './samples/adapter/items-count.component';
36-
import { DemoBofEofComponent } from './samples/adapter/bof-eof.component';
37-
import { DemoFirstLastVisibleItemsComponent } from './samples/adapter/first-last-visible-items.component';
38-
import { DemoAppendPrependComponent } from './samples/adapter/append-prepend.component';
39-
import { DemoAppendPrependSyncComponent } from './samples/adapter/append-prepend-sync.component';
40-
import { DemoIsLoadingExtendedComponent } from './samples/adapter/is-loading-extended.component';
41-
import { DemoInsertComponent } from './samples/adapter/insert.component';
42-
import { DemoCheckSizeComponent } from './samples/adapter/check-size.component';
43-
import { DemoRemoveComponent } from './samples/adapter/remove.component';
44-
import { DemoClipComponent } from './samples/adapter/clip.component';
45-
import { DemoDatasourceSignaturesComponent } from './samples/datasource/datasource-signatures.component';
46-
import { DemoBidirectionalUnlimitedDatasourceComponent } from './samples/datasource/bidirectional-unlimited-datasource.component';
47-
import { DemoLimitedDatasourceComponent } from './samples/datasource/limited-datasource.component';
48-
import { DemoPositiveLimitedDatasourceComponent } from './samples/datasource/positive-limited-datasource.component';
49-
import { RemoteDataService, DemoRemoteDatasourceComponent } from './samples/datasource/remote-datasource.component';
50-
import { DemoInvertedDatasourceComponent } from './samples/datasource/inverted-datasource.component';
51-
import { DemoPagesDatasourceComponent } from './samples/datasource/pages-datasource.component';
52-
import { DemoAdapterRelaxComponent } from './samples/experimental/adapter-relax.component';
53-
import { DemoViewportElementSettingComponent } from './samples/experimental/viewportElement-setting.component';
54-
import { DemoInverseSettingComponent } from './samples/experimental/inverse-setting.component';
55-
import { DemoAdapterFixPositionComponent } from './samples/experimental/adapter-fix-position.component';
56-
import { DemoAdapterFixUpdaterComponent } from './samples/experimental/adapter-fix-updater.component';
57-
import { DemoAdapterFixScrollToItemComponent } from './samples/experimental/adapter-fix-scrollToItem.component';
5820
import { WindowComponent } from './samples/window.component';
5921
import { TestComponent, TestInnerComponent } from './samples/test.component';
6022

23+
import demos from './demos';
24+
25+
import { RemoteDataService } from './samples/datasource/remote-datasource.component';
6126
import { AppRoutingModule } from './app-routing.module';
6227

6328
@NgModule({
@@ -72,46 +37,13 @@ import { AppRoutingModule } from './app-routing.module';
7237
AdapterComponent,
7338
DatasourceComponent,
7439
ExperimentalComponent,
75-
DemoBasicComponent,
76-
DemoBufferSizeComponent,
77-
DemoPaddingComponent,
78-
DemoItemSizeComponent,
79-
DemoStartIndexComponent,
80-
DemoMinMaxIndexesComponent,
81-
DemoInfiniteComponent,
82-
DemoHorizontalComponent,
83-
DemoDifferentHeightsComponent,
84-
DemoWindowViewportComponent,
85-
DemoAdapterReturnValueComponent,
86-
DemoResetComponent,
87-
DemoReloadComponent,
88-
DemoIsLoadingComponent,
89-
DemoItemsCountComponent,
90-
DemoBofEofComponent,
91-
DemoFirstLastVisibleItemsComponent,
92-
DemoAppendPrependComponent,
93-
DemoAppendPrependSyncComponent,
94-
DemoIsLoadingExtendedComponent,
95-
DemoInsertComponent,
96-
DemoCheckSizeComponent,
97-
DemoRemoveComponent,
98-
DemoClipComponent,
99-
DemoDatasourceSignaturesComponent,
100-
DemoBidirectionalUnlimitedDatasourceComponent,
101-
DemoLimitedDatasourceComponent,
102-
DemoPositiveLimitedDatasourceComponent,
103-
DemoRemoteDatasourceComponent,
104-
DemoInvertedDatasourceComponent,
105-
DemoPagesDatasourceComponent,
106-
DemoAdapterRelaxComponent,
107-
DemoViewportElementSettingComponent,
108-
DemoInverseSettingComponent,
109-
DemoAdapterFixPositionComponent,
110-
DemoAdapterFixUpdaterComponent,
111-
DemoAdapterFixScrollToItemComponent,
11240
WindowComponent,
11341
TestComponent,
114-
TestInnerComponent
42+
TestInnerComponent,
43+
...demos.common,
44+
...demos.datasource,
45+
...demos.adapter,
46+
...demos.experimental,
11547
],
11648
imports: [
11749
BrowserModule,

demo/app/demos.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { DemoBasicComponent } from './samples/common/basic.component';
2+
import { DemoBufferSizeComponent } from './samples/common/buffer-size.component';
3+
import { DemoPaddingComponent } from './samples/common/padding.component';
4+
import { DemoItemSizeComponent } from './samples/common/item-size.component';
5+
import { DemoStartIndexComponent } from './samples/common/start-index.component';
6+
import { DemoMinMaxIndexesComponent } from './samples/common/min-max-indexes.component';
7+
import { DemoInfiniteComponent } from './samples/common/infinite.component';
8+
import { DemoHorizontalComponent } from './samples/common/horizontal.component';
9+
import { DemoDifferentHeightsComponent } from './samples/common/different-heights.component';
10+
import { DemoWindowViewportComponent } from './samples/common/window-viewport.component';
11+
12+
import { DemoDatasourceSignaturesComponent } from './samples/datasource/datasource-signatures.component';
13+
import { DemoBidirectionalUnlimitedDatasourceComponent } from './samples/datasource/bidirectional-unlimited-datasource.component';
14+
import { DemoLimitedDatasourceComponent } from './samples/datasource/limited-datasource.component';
15+
import { DemoPositiveLimitedDatasourceComponent } from './samples/datasource/positive-limited-datasource.component';
16+
import { DemoRemoteDatasourceComponent } from './samples/datasource/remote-datasource.component';
17+
import { DemoInvertedDatasourceComponent } from './samples/datasource/inverted-datasource.component';
18+
import { DemoPagesDatasourceComponent } from './samples/datasource/pages-datasource.component';
19+
20+
import { DemoAdapterRelaxComponent } from './samples/adapter/adapter-relax.component';
21+
import { DemoAdapterReturnValueComponent } from './samples/adapter/adapter-return-value.component';
22+
import { DemoResetComponent } from './samples/adapter/reset.component';
23+
import { DemoReloadComponent } from './samples/adapter/reload.component';
24+
import { DemoIsLoadingComponent } from './samples/adapter/is-loading.component';
25+
import { DemoItemsCountComponent } from './samples/adapter/items-count.component';
26+
import { DemoBofEofComponent } from './samples/adapter/bof-eof.component';
27+
import { DemoFirstLastVisibleItemsComponent } from './samples/adapter/first-last-visible-items.component';
28+
import { DemoAppendPrependComponent } from './samples/adapter/append-prepend.component';
29+
import { DemoAppendPrependSyncComponent } from './samples/adapter/append-prepend-sync.component';
30+
import { DemoIsLoadingExtendedComponent } from './samples/adapter/is-loading-extended.component';
31+
import { DemoInsertComponent } from './samples/adapter/insert.component';
32+
import { DemoCheckSizeComponent } from './samples/adapter/check-size.component';
33+
import { DemoRemoveComponent } from './samples/adapter/remove.component';
34+
import { DemoClipComponent } from './samples/adapter/clip.component';
35+
36+
import { DemoViewportElementSettingComponent } from './samples/experimental/viewportElement-setting.component';
37+
import { DemoInverseSettingComponent } from './samples/experimental/inverse-setting.component';
38+
import { DemoAdapterFixPositionComponent } from './samples/experimental/adapter-fix-position.component';
39+
import { DemoAdapterFixUpdaterComponent } from './samples/experimental/adapter-fix-updater.component';
40+
import { DemoAdapterFixScrollToItemComponent } from './samples/experimental/adapter-fix-scrollToItem.component';
41+
import { DemoOnBeforeClipSettingComponent } from './samples/experimental/onBeforeClip-setting.component';
42+
43+
const common = [
44+
DemoBasicComponent,
45+
DemoBufferSizeComponent,
46+
DemoPaddingComponent,
47+
DemoItemSizeComponent,
48+
DemoStartIndexComponent,
49+
DemoMinMaxIndexesComponent,
50+
DemoInfiniteComponent,
51+
DemoHorizontalComponent,
52+
DemoDifferentHeightsComponent,
53+
DemoWindowViewportComponent,
54+
];
55+
56+
const datasource = [
57+
DemoDatasourceSignaturesComponent,
58+
DemoBidirectionalUnlimitedDatasourceComponent,
59+
DemoLimitedDatasourceComponent,
60+
DemoPositiveLimitedDatasourceComponent,
61+
DemoRemoteDatasourceComponent,
62+
DemoInvertedDatasourceComponent,
63+
DemoPagesDatasourceComponent,
64+
];
65+
66+
const adapter = [
67+
DemoAdapterRelaxComponent,
68+
DemoAdapterReturnValueComponent,
69+
DemoResetComponent,
70+
DemoReloadComponent,
71+
DemoIsLoadingComponent,
72+
DemoItemsCountComponent,
73+
DemoBofEofComponent,
74+
DemoFirstLastVisibleItemsComponent,
75+
DemoAppendPrependComponent,
76+
DemoAppendPrependSyncComponent,
77+
DemoIsLoadingExtendedComponent,
78+
DemoInsertComponent,
79+
DemoCheckSizeComponent,
80+
DemoRemoveComponent,
81+
DemoClipComponent,
82+
];
83+
84+
const experimental = [
85+
DemoViewportElementSettingComponent,
86+
DemoInverseSettingComponent,
87+
DemoAdapterFixPositionComponent,
88+
DemoAdapterFixUpdaterComponent,
89+
DemoAdapterFixScrollToItemComponent,
90+
DemoOnBeforeClipSettingComponent,
91+
];
92+
93+
export default {
94+
common,
95+
datasource,
96+
adapter,
97+
experimental
98+
};

demo/app/samples/adapter.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ <h1>Angular UI Scroll Adapter Demos</h1>
2323
<pre>{{importSample}}</pre>
2424

2525
<app-demo-adapter-return-value></app-demo-adapter-return-value>
26+
<app-adapter-relax></app-adapter-relax>
2627
<app-demo-reload></app-demo-reload>
2728
<app-demo-reset></app-demo-reset>
2829
<app-demo-is-loading></app-demo-is-loading>

demo/app/samples/experimental/adapter-relax.component.html renamed to demo/app/samples/adapter/adapter-relax.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<app-demo [datasource]="datasource" [context]="demoContext" [sources]="sources">
22

33
<div actions>
4-
<div class="comment">Available since v1.7.0, undocumented</div>
54
<button (click)="doReplace()">replace (5, 6, 7) with (5 *)</button>
65
</div>
76

demo/app/samples/experimental/adapter-relax.component.ts renamed to demo/app/samples/adapter/adapter-relax.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Datasource } from '../../../../public_api';
1010
export class DemoAdapterRelaxComponent {
1111

1212
demoContext = {
13-
scope: 'experimental',
13+
scope: 'adapter',
1414
title: `Adapter relax`,
1515
titleId: `adapter-relax`,
1616
noInfo: true

demo/app/samples/adapter/bof-eof.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { BehaviorSubject, Subject, merge, Subscription } from 'rxjs';
2+
import { merge } from 'rxjs';
33

44
import { DemoContext, DemoSources, DemoSourceType } from '../../shared/interfaces';
55
import { doLog } from '../../shared/datasource-get';

demo/app/samples/adapter/insert.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component } from '@angular/core';
2-
import { BehaviorSubject, Subject, merge, Subscription } from 'rxjs';
32

43
import { DemoContext, DemoSources, DemoSourceType } from '../../shared/interfaces';
54

demo/app/samples/adapter/reload.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,12 @@
2424
the default value 1 will be used.
2525
See also <a href="#/settings#start-index">startIndex setting description</a>.
2626
</p>
27+
<p>
28+
The <em>Adapter.reload</em> method is safe and needs not to be protected
29+
with the <em>Adapter.relax</em> (though it could be protected if the UX demands).
30+
This method interrupts the <em>uiScroll</em> flow and synchronously terminates
31+
any pending processes on the Scroller's end.
32+
The same is true also for the <em>Adapter.reset</em> method.
33+
</p>
2734
</div>
2835
</app-demo>

demo/app/samples/adapter/reload.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component } from '@angular/core';
33
import { DemoContext, DemoSources, DemoSourceType } from '../../shared/interfaces';
44
import { datasourceGetCallbackInfinite } from '../../shared/datasource-get';
55

6-
import { Datasource, IDatasource } from '../../../../public_api'; // from 'ngx-ui-scroll';
6+
import { Datasource } from '../../../../public_api'; // from 'ngx-ui-scroll';
77

88
@Component({
99
selector: 'app-demo-reload',

0 commit comments

Comments
 (0)