diff --git a/src/scripts/classes/mapping/platform-user.ts b/src/scripts/classes/mapping/platform-user.ts index e497cf5..24bc0f0 100644 --- a/src/scripts/classes/mapping/platform-user.ts +++ b/src/scripts/classes/mapping/platform-user.ts @@ -15,11 +15,12 @@ import { fetchHTML } from "../../network-helper"; import { GENERIC, MEMBER } from "../../constants/css-selector"; import shared from "../../shared"; import { UserNotLogged, USER_NOT_LOGGED } from "../errors"; +import { ILazy } from "../../interfaces"; /** * Represents a generic user registered on the platform. */ -export default class PlatformUser { +export default class PlatformUser implements ILazy { //#region Fields private _id: number; diff --git a/src/scripts/classes/mapping/post.ts b/src/scripts/classes/mapping/post.ts index 5f16abf..f63c7e3 100644 --- a/src/scripts/classes/mapping/post.ts +++ b/src/scripts/classes/mapping/post.ts @@ -16,11 +16,12 @@ import { urls } from "../../constants/url"; import { fetchHTML } from "../../network-helper"; import shared from "../../shared"; import { UserNotLogged, USER_NOT_LOGGED } from "../errors"; +import { ILazy } from "../../interfaces"; /** * Represents a post published by a user on the F95Zone platform. */ -export default class Post { +export default class Post implements ILazy { //#region Fields private _id: number; diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index a87d177..12e0611 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -12,7 +12,7 @@ import { DateTime } from "luxon"; // Modules from files import Post from "./post"; import PlatformUser from "./platform-user"; -import { TCategory, TRating } from "../../interfaces"; +import { ILazy, TCategory, TRating } from "../../interfaces"; import { urls } from "../../constants/url"; import { POST, THREAD } from "../../constants/css-selector"; import { fetchHTML, fetchPOSTResponse } from "../../network-helper"; @@ -31,7 +31,7 @@ import shared from "../../shared"; /** * Represents a generic F95Zone platform thread. */ -export default class Thread { +export default class Thread implements ILazy { //#region Fields private POST_FOR_PAGE = 20; diff --git a/src/scripts/interfaces.ts b/src/scripts/interfaces.ts index 79119af..c9677e0 100644 --- a/src/scripts/interfaces.ts +++ b/src/scripts/interfaces.ts @@ -316,3 +316,15 @@ export interface IQuery { */ execute(): any; } + +/** + * It represents an object that obtains the data + * only on the explicit request of the user and + * only after its establishment. + */ +export interface ILazy { + /** + * Gets the data relating to the object. + */ + fetch(): Promise; +}