This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Focusable abstract class and refactor Actor and Attribute
Introduced a new abstract class called `Focusable` to encapsulate the common `Optional` usage in `Actor` and `Attribute` classes. The `Focusable` class represents focusable objects and gives access and modification of a property or element in a given subject via Optional. Refactoring in the `Actor` and `Attribute` classes removes duplicate code, enhancing code readability and maintainability.
- Loading branch information
1 parent
bac81f8
commit 713b6d7
Showing
5 changed files
with
35 additions
and
20 deletions.
There are no files selected for viewing
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
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,4 @@ | ||
export * from "./range" | ||
export * from "./error" | ||
export * from "./optics" | ||
export * from "./string" |
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,26 @@ | ||
import {Optional} from "@fp-ts/optic" | ||
|
||
/** | ||
* Represents an abstract class for focusable objects. | ||
* | ||
* This class provides an {@link Optional} that allows accessing and modifying a property or element in a | ||
* given subject. | ||
* | ||
* @template TSubject The type of the subject on which the focus will be applied. | ||
* @template TFocus The type of the property or element that will be focused. | ||
*/ | ||
export abstract class Focusable<TSubject, TFocus> { | ||
|
||
/** | ||
* Creates a new instance of the focusable object. | ||
*/ | ||
protected constructor( | ||
/** | ||
* Represents an {@link Optional} that focuses on TFocus in a given TSubject. | ||
* | ||
* @readonly | ||
*/ | ||
protected readonly optic: Optional<TSubject, TFocus> | ||
) { | ||
} | ||
} |
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
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