Skip to content
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

feat: Remove hybridContext and memorySize from Swift HybridObjects (make them optional) #420

Merged
merged 5 commits into from
Dec 17, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Dec 11, 2024

In Swift Hybrid Objects we previously always required the user to fill in hybridContext and memorySize because Swift protocols don't allow default values, and there's no abstract class in Swift.

I found a solution with a typealias tho, and now we can pre-fill hybridContext and memorySize!

For library users, this now means you can remove those fields from your Swift class;

 class HybridMath: HybridMathSpec {
-  var hybridContext: margelo.nitro.HybridContext = .init()
-  var memorySize: Int { return getSizeOf(self) }  
    var pi: Double { return 3.1415 } 
 }

If you have a custom type that is heavy on memory, it is still recommended to override memorySize;

class HybridImage: HybridImageSpec {
  override var memorySize: Int { return nativeImage.height * nativeImage.bytesPerRow }  
}

THIS IS A BREAKING CHANGE

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Dec 13, 2024 2:29pm

@mrousavy mrousavy merged commit 6b85f08 into main Dec 17, 2024
8 checks passed
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.

1 participant