-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added generic types for StrategySetupService and extending default st…
…rategy names with custom ones
- Loading branch information
kajetan.swiatek
committed
Jul 30, 2020
1 parent
08eb759
commit 4b53585
Showing
13 changed files
with
74 additions
and
56 deletions.
There are no files selected for viewing
9 changes: 5 additions & 4 deletions
9
libs/template/src/lib/render-strategies/interfaces/add-strategy-request.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
libs/template/src/lib/render-strategies/interfaces/available-strategies.interface.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
libs/template/src/lib/render-strategies/interfaces/default-strategies.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { NoopStrategyConstructor } from './noop-strategy-constructor.type'; | ||
import { StrategyConstructor } from './strategy-constructor.type'; | ||
|
||
export interface DefaultStrategies { | ||
global: StrategyConstructor; | ||
native: StrategyConstructor; | ||
local: StrategyConstructor; | ||
detach: StrategyConstructor; | ||
noop: NoopStrategyConstructor; | ||
} |
3 changes: 3 additions & 0 deletions
3
libs/template/src/lib/render-strategies/interfaces/default-strategy-name.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { DefaultStrategies } from './default-strategies.interface'; | ||
|
||
export type DefaultStrategyName = keyof DefaultStrategies; |
9 changes: 9 additions & 0 deletions
9
libs/template/src/lib/render-strategies/interfaces/extended-strategy.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { NoopStrategyConstructor } from './noop-strategy-constructor.type'; | ||
import { StrategyConstructor } from './strategy-constructor.type'; | ||
import { DefaultStrategyName } from './default-strategy-name.type'; | ||
|
||
export type ExtendedStrategies<S extends string = DefaultStrategyName> = { | ||
[key in S | DefaultStrategyName]: | ||
| StrategyConstructor | ||
| NoopStrategyConstructor; | ||
}; |
9 changes: 7 additions & 2 deletions
9
libs/template/src/lib/render-strategies/interfaces/noop-strategy-constructor.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { RenderStrategy } from '../../core/render-aware'; | ||
import { | ||
RenderStrategy, | ||
RenderStrategyFactoryConfig | ||
} from '../../core/render-aware'; | ||
|
||
export type NoopStrategyConstructorType = () => RenderStrategy; | ||
export type NoopStrategyConstructor = ( | ||
config?: RenderStrategyFactoryConfig | ||
) => RenderStrategy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
libs/template/src/lib/render-strategies/interfaces/strategy-name.type.ts
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
libs/template/src/lib/render-strategies/interfaces/strategy-setup-state.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { AvailableStrategies } from './available-strategies.interface'; | ||
import { StrategyNameType } from './strategy-name.type'; | ||
import { ExtendedStrategies } from './extended-strategy'; | ||
import { DefaultStrategyName } from './default-strategy-name.type'; | ||
|
||
export interface StrategySetupState { | ||
strategies: AvailableStrategies; | ||
currentStrategy: StrategyNameType; | ||
currentOutOfViewportStrategy: StrategyNameType; | ||
export interface StrategySetupState<S extends string = DefaultStrategyName> { | ||
strategies: ExtendedStrategies<S>; | ||
currentStrategy: keyof ExtendedStrategies<S>; | ||
currentOutOfViewportStrategy: keyof ExtendedStrategies<S>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
libs/template/src/lib/render-strategies/tokens/available-strategies.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
libs/template/src/lib/render-strategies/tokens/default-out-of-viewport-strategy.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
libs/template/src/lib/render-strategies/tokens/default-strategy.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
import { StrategyNameType } from '../interfaces/strategy-name.type'; | ||
import { DefaultStrategyName } from '../interfaces/default-strategy-name.type'; | ||
|
||
export const RX_ANGULAR_DEFAULT_STRATEGY = new InjectionToken<StrategyNameType>( | ||
'Default strategy', | ||
{ | ||
providedIn: 'root', | ||
factory: () => 'local' | ||
} | ||
); | ||
export const RX_ANGULAR_DEFAULT_STRATEGY = new InjectionToken< | ||
DefaultStrategyName | ||
>('Default strategy', { | ||
providedIn: 'root', | ||
factory: () => 'local' | ||
}); |