On 8/8/16, 8:32 AM, "Harbs" <[email protected]> wrote:

>How do I do that without ending up with double code in my app? If one
>part of the app uses Image and another uses ImageWithBlob, that’s going
>to duplicate about 600 lines of code.

Why wouldn't all of your code use ImageWithBlob?  Also, why wouldn't
ImageWithBlob subclass Image to share most of that code, and
ImageViewWithBlob subclass ImageView?

I should point out that, with beads, the outer component is really
supposed to be a shell or wrapper.  An exercise Peter and I try to do when
creating new components is to make sure they are truly aggregations.  IOW,

   <js:Image source="foo.png" />

Which loads ImageModel and ImageView by default, should be replaceable in
your MXML with

   <js:UIBase>
     <js:beads>
       <js:ImageModel source="foo.png" />
       <js:ImageView />
     </js:beads>
   </js:UIBase>

All Image does is subclass UIBase and proxy the model's source property to
the component's API surface.

It sounds like in your app, you want one single Image component that takes
a url or binary blob.  We can't overload the source property right now, so
you'll have to use a different property name like "binary", but
essentially I think you want to allow:

   <js:UIBase>
     <js:beads>
       <js:ImageModelWithBlob binary="bunchofbytes" />
       <js:ImageViewWithBlob />
     </js:beads>
   </js:UIBase>

Or even:

   <js:Image>
     <js:beads>
       <js:ImageModelWithBlob binary="bunchofbytes" />
       <js:ImageViewWithBlob />
     </js:beads>
   </js:Image>

And then you could aggregate the last pattern by having ImageWithBlob
subclass Image and proxy the binary property and maybe add a src property
that switches between source and binary.  That's why I would expect
ImageModelWithBlob could subclass ImageModel and ImageViewWithBlog could
subclass ImageView and only add support for "binary".



FWIW, I used the property name "source" for Image because Flex did, and I
don't like using abbreviations like "src" like the <img/> tag does, but if
folks would rather use "src" or "url" for the String source and "source"
as an Object that can take Blob or String, that's fine with me.

-Alex

Reply via email to