-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user info to assetViewModel (Breaking Change) #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update documentation about this as well
*/ | ||
public required init(_ data: T) { | ||
public required init(_ data: T, userInfo: [CodingUserInfoKey: Any]? = nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be optional? or default to [:]
?
@@ -75,7 +80,7 @@ open class ControlledAsset<DataType: AssetData, ModelType>: SwiftUIAsset where M | |||
decoder.logger?.t("Updating model for \(data.id)") | |||
model.data = data | |||
} else { | |||
self.model = ModelType(data) | |||
self.model = ModelType(data, userInfo: decoder.userInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update the userInfo
when we get the model from the cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call
@@ -15,16 +15,21 @@ open class AssetViewModel<T: AssetData>: ObservableObject { | |||
/// The decoded data | |||
@Published public var data: T | |||
|
|||
/// Any contextual information set by the user | |||
public var userInfo: [CodingUserInfoKey: Any]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't need to update this, we can make this let
instead of var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kept it as var in order to set the userinfo
when we update the model from cache
not sure why the following tests InfoAssetUITests.testInfoBasic(), InputAssetUITests.testBasicInput(), InputAssetUITests.testInputValidation() keep failing for eyes not finding elements, but passes locally when i run them |
Model can now access the userInfo which can contain information set by the user usually through the plugins (SwiftUIPendingTransactionPlugin, SwiftUIBeaconContextPlugin) which will come later in OSS
Change Type (required)
Indicate the type of change your pull request is:
patch
minor
major
Version
Published prerelease version:
0.4.0-next.12
Changelog
Release Notes
Android: add note to input ref asset (#192)
Add note field to input reference asset
Export InfoAsset as XLR View (#139)
Export Info Asset as XLR View
sync up to latest (#131)
Sync latest code
Expose utils for expression LSP (#117)
parseExpression
from the expression parserstrict
flag toparseExpression
that will (when disabled) attach any parsing errors to the top-level node instead of throwingDeps/bump dependencies (#111)
Dependency upgrades
Sync Latest Player Code (#109)
Syncs to latest version and bumps tapable-ts to latest version.
🚀 Enhancement
🐛 Bug Fix
📝 Documentation
Authors: 15