Coder Social home page Coder Social logo

Comments (6)

cadnza avatar cadnza commented on June 18, 2024

Property wrappers and macro annotations should also accept parameters such that it would be possible to generate this example of the @SmallNumber property wrapper defined in tutorial:

struct NarrowRectangle {
    @SmallNumber(wrappedValue: 2, maximum: 5) var height: Int
    @SmallNumber(wrappedValue: 3, maximum: 4) var width: Int
}

from uniffi-rs.

cadnza avatar cadnza commented on June 18, 2024

Also, I don't see much of a need for UniFFI to define Swift property wrappers or macros—it should only need to apply them. So if you attach e.g. #[uniffi::swift_macro(tasty(tastiness = 3))] to a struct, it should take it on faith that the @tasty macro already has a definition somewhere on the Swift side and then proceed to blindly apply the @tasty(tastiness: 3) annotation to the generated Swift type. Done that way, UniFFI can remain reasonably decoupled from the Swift release cycle in terms of property wrappers and macros, and UniFFI can apply any property wrapper or macro that exists anywhere on the Swift side.

from uniffi-rs.

mhammond avatar mhammond commented on June 18, 2024

That sounds great, but difficult to express in UniFFI's model. Happy to help if you want to have a start at this though.

from uniffi-rs.

cadnza avatar cadnza commented on June 18, 2024

@mhammond Thanks! Turns out there's already a convention for writing SwiftUI code with UniFFI, and it's a lot less complicated and more sustainable than this feature would be 😄 Thanks for humoring my whim. Closing as not planned.

from uniffi-rs.

GraniteLake avatar GraniteLake commented on June 18, 2024

@cadnza What is the convention for writing SwiftUI code with UniFFI with regard to having a view update when a field in a UniFFi Interface / rust struct changes?

from uniffi-rs.

cadnza avatar cadnza commented on June 18, 2024

@cadnza What is the convention for writing SwiftUI code with UniFFI with regard to having a view update when a field in a UniFFi Interface / rust struct changes?

@GraniteLake As far as I understand—first pointing out how wide and varied my lack of experience is with this—the way it's usually done is by writing an intermediary stuct/class in Swift that wraps UniFFI's class and adds SwiftUI's property wrappers and macro annotations. As far as how you get UniFFI to update the struct based on those wrappers and annotations, I'm not sure, but something along those lines is what I've been seeing going through other peoples' code.

from uniffi-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.