Skip to content

Web SDK Refactor: Add ModelStore Class#1269

Merged
fadi-george merged 4 commits into
web-refractorfrom
fg/op-model-2
Apr 16, 2025
Merged

Web SDK Refactor: Add ModelStore Class#1269
fadi-george merged 4 commits into
web-refractorfrom
fg/op-model-2

Conversation

@fadi-george

@fadi-george fadi-george commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Description

Continuation of the Web SDK Refactor project. This pr is focuses on porting the follow classes/types from the Android SDK: ModelStore , OperationModelStore

Details

  • adds ModelStore class
  • adds new addAt to ModelStore since cant have overloading for add method
  • adds OperationModelStore class but comment out the case options for the create method
  • name old Operation to LegacyOperation

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable


Base automatically changed from fg/op-model-1 to web-refractor April 16, 2025 17:58
@fadi-george fadi-george merged commit 13c85db into web-refractor Apr 16, 2025
@fadi-george fadi-george deleted the fg/op-model-2 branch April 16, 2025 18:37
}

/**
* @returns list of read-only models, cloned for thread safety

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloned for thread safety

nit: is this still true? I'm not sure if the ported implementation uses anything more complex than async/awaits.

persist(): void {
if (!this.name || !this._prefs || !this.hasLoadedFromCache) return;

const jsonArray: unknown[] = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is it possible to use a stronger type here? I guess it would be difficult without refactoring the return type on toJSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants