Skip to content

Commit

Permalink
🚡
Browse files Browse the repository at this point in the history
  • Loading branch information
jpzwarte committed Oct 7, 2024
1 parent 8f6cd15 commit ffbb1aa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/components/data-source/src/array-data-source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('ArrayDataSource', () => {
it('should emit an sl-update event when calling update()', () => {
const onUpdate = spy();

ds.addEventListener('sl-data-source-update', onUpdate);
ds.addEventListener('sl-update', onUpdate);
ds.update();

expect(onUpdate).to.have.been.calledOnce;
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('ArrayDataSource', () => {
expect(ds.items.map(({ firstName }) => firstName)).to.deep.equal(['John', 'Jane', 'Bob', 'Ann', 'Ann']);
});

it('should reset the filtered items when removing a sort', () => {
it('should reset the original order when removing a sort', () => {
ds.setSort('id', 'firstName', 'asc');
ds.update();

Expand Down
2 changes: 1 addition & 1 deletion packages/components/data-source/src/array-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ export class ArrayDataSource<T = any> extends DataSource<T> {
}

this.#filteredItems = items;
this.dispatchEvent(new CustomEvent('sl-data-source-update', { detail: { dataSource: this } }));
this.dispatchEvent(new CustomEvent('sl-update', { detail: { dataSource: this } }));
}
}
2 changes: 1 addition & 1 deletion packages/components/data-source/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare global {
interface GlobalEventHandlersEventMap {
'sl-data-source-update': DataSourceUpdateEvent;
'sl-update': DataSourceUpdateEvent;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/components/data-source/src/fetch-data-source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('FetchDataSource', () => {
it('should emit an update event when calling update()', () => {
const onUpdate = spy();

ds.addEventListener('sl-data-source-update', onUpdate);
ds.addEventListener('sl-update', onUpdate);
ds.update();

expect(onUpdate).to.have.been.calledOnce;
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('FetchDataSource', () => {
const onUpdate = spy();

ds.update();
ds.addEventListener('sl-data-source-update', onUpdate);
ds.addEventListener('sl-update', onUpdate);
ds.items.at(0);

expect(onUpdate).not.to.have.been.called;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/data-source/src/fetch-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class FetchDataSource<T = any> extends DataSource<T> {
this.#items = new Array<T>(this.size);
this.#pages = {};
this.#proxy = this.#createProxy(this.#items);
this.dispatchEvent(new CustomEvent('sl-data-source-update', { detail: { dataSource: this } }));
this.dispatchEvent(new CustomEvent('sl-update', { detail: { dataSource: this } }));
}

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ export class FetchDataSource<T = any> extends DataSource<T> {
this.#items[pageSize * (page - 1) + i] = res.items[i];
}

this.dispatchEvent(new CustomEvent('sl-data-source-update', { detail: { dataSource: this } }));
this.dispatchEvent(new CustomEvent('sl-update', { detail: { dataSource: this } }));
})();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/components/grid/src/view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class GridViewModel<T = any> {

set dataSource(dataSource: DataSource<T> | undefined) {
if (this.#dataSource) {
this.#dataSource.removeEventListener('sl-data-source-update', this.update);
this.#dataSource.removeEventListener('sl-update', this.update);
}

this.#dataSource = dataSource;
this.#dataSource?.addEventListener('sl-data-source-update', this.update);
this.#dataSource?.addEventListener('sl-update', this.update);

this.update();
}
Expand Down

0 comments on commit ffbb1aa

Please sign in to comment.