Giter Site home page Giter Site logo

Transferables about webidl HOT 6 CLOSED

whatwg avatar whatwg commented on May 27, 2024
Transferables

from webidl.

Comments (6)

marcoscaceres avatar marcoscaceres commented on May 27, 2024

The use case for this is really having a dictionary that is passed to .postMessage().

Today, we use any data:

interface WhatEver{
   void postMessage(DOMString url, any data, NfcMessageDeliveredCallback); 
}

But what I want is something like:

transferable dictionary WhateverData {

}

interface WhatEver{
   void postMessage(DOMString url, WhateverData data, someCallBack); 
}

When WhateverData.postMessage() is invoked, the structured clone algo would be run on WhateverData.

cc: @kenchris

from webidl.

bzbarsky avatar bzbarsky commented on May 27, 2024

Is the idea to only clone some of the dictionary's properties but not all of them?

Or is the idea to not change UA behavior at all from what it would be with "any" and invoking the structured clone algorithm in prose, so this would just be a form of documentation?

from webidl.

marcoscaceres avatar marcoscaceres commented on May 27, 2024

Is the idea to only clone some of the dictionary's properties but not all of them?

Yes, this is what I was thinking.

Or is the idea to not change UA behavior at all from what it would be with "any" and invoking the structured clone algorithm in prose, so this would just be a form of documentation?

That's what I'm kinda hoping we can discuss in this bug. If you are passing a transferable Dictionary, then I think it would be fine to just throw out all the unknown stuff in the cloning process.

from webidl.

bzbarsky avatar bzbarsky commented on May 27, 2024

Yes, this is what I was thinking.

OK. Note that you can already do this by having the dictionary in the IDL and then in prose converting the dictionary to a JS value and then structured cloning that value. It's a bit nonobvious, but quite possible.

Is this something people commonly want to do?

from webidl.

marcoscaceres avatar marcoscaceres commented on May 27, 2024

OK. Note that you can already do this by having the dictionary in the IDL and then in prose converting the dictionary to a JS value and then structured cloning that value. It's a bit nonobvious, but quite possible.

Agree - it's certainly doable. Just figured it would be cleaner to take it out of prose.

Is this something people commonly want to do?

I don't think it's very common - but I've seen it come up a few times in various context/discussions. I'll see if I can gather more real examples over time.

from webidl.

marcoscaceres avatar marcoscaceres commented on May 27, 2024

(closing for now ... thanks for clarifications @bzbarsky!)

from webidl.

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.