Skip to content

Commit

Permalink
fix typings for ngx-ui-scroll integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilt committed Apr 16, 2021
1 parent 0b9fc6d commit 759167f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/classes/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,16 @@ export class Adapter<Item = unknown> implements IAdapter<Item> {
: defaultMethod.apply(this, args);
}

constructor(publicContext: IAdapter<Item> | null, getWorkflow: WorkflowGetter<Item>, logger: Logger) {
constructor(context: IAdapter<Item> | null, getWorkflow: WorkflowGetter<Item>, logger: Logger) {
this.getWorkflow = getWorkflow;
this.logger = logger;
this.relax$ = null;
this.relaxRun = null;
this.reloadCounter = 0;
const context: AdapterContext | null = publicContext ? (publicContext as unknown as AdapterContext) : null;

// public context stores Reactive props configuration
const reactivePropsStore: IReactivePropsStore =
context && context.reactiveConfiguredProps || {};
context && (context as AdapterContext).reactiveConfiguredProps || {};

// make array of the original values from public context if present
const adapterProps = context
Expand Down Expand Up @@ -221,7 +220,7 @@ export class Adapter<Item = unknown> implements IAdapter<Item> {
} else if (type === AdapterPropType.WorkflowRunner) {
value = this.getPromisifiedMethod(value as MethodResolver, defaultValue as MethodResolver);
} else if (type === AdapterPropType.Reactive && reactivePropsStore[name]) {
value = context[name];
value = (context as IAdapter)[name];
}
Object.defineProperty(context, name, {
configurable: false,
Expand All @@ -232,7 +231,7 @@ export class Adapter<Item = unknown> implements IAdapter<Item> {
});

// public context cleanup
delete context.reactiveConfiguredProps;
delete (context as AdapterContext).reactiveConfiguredProps;
}

initialize(buffer: Buffer<Item>, state: State, logger: Logger, adapterRun$?: Reactive<ProcessSubject>): void {
Expand Down
3 changes: 2 additions & 1 deletion src/inputs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Direction } from './direction';
import { ValidatorType, VALIDATORS, validateOne, validate } from './validation';
import { DATASOURCE } from './datasource';
import { DatasourceProps, DATASOURCE } from './datasource';
import { SETTINGS, DEV_SETTINGS } from './settings';
import { AdapterMethods, ADAPTER_METHODS } from './adapter';

Expand All @@ -10,6 +10,7 @@ export {
VALIDATORS,
validateOne,
validate,
DatasourceProps,
DATASOURCE,
SETTINGS,
DEV_SETTINGS,
Expand Down
9 changes: 5 additions & 4 deletions src/processes/adapter/reset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Scroller } from '../../scroller';
import { ADAPTER_METHODS } from '../../inputs/index';
import { DatasourceProps } from '../../inputs/index';
import { Datasource } from '../../classes/datasource';
import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';
import { IDatasourceOptional, ProcessPayload } from '../../interfaces/index';
Expand All @@ -15,10 +15,11 @@ export default class Reset extends BaseAdapterProcessFactory(AdapterProcess.rese
return;
}
const constructed = options instanceof Datasource;
Object.keys(ADAPTER_METHODS[Reset.process]).forEach(key => {
Object.keys(DatasourceProps).forEach(key => {
const param = data.params[key];
if (param.isSet || (constructed && datasource[key])) {
datasource[key] = param.value;
const ds = datasource as unknown as { [key: string]: unknown };
if (param.isSet || (constructed && ds[key])) {
ds[key] = param.value;
}
});
}
Expand Down

0 comments on commit 759167f

Please sign in to comment.