Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

piotrz
Hi Yishay,

I'm wondering whether it is possible to have it bead instead class ? What
do you think ?

Thanks, Piotr

2017-07-10 18:30 GMT+02:00 <[hidden email]>:

> Repository: flex-asjs
> Updated Branches:
>   refs/heads/develop c6a24011b -> 54d00a044
>
>
> Add FileUploaderWithResponseData
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/54d00a04
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/54d00a04
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/54d00a04
>
> Branch: refs/heads/develop
> Commit: 54d00a044196ec62e81840b3134f9f17f26f4cb1
> Parents: c6a2401
> Author: DESKTOP-RH4S838\Yishay <[hidden email]>
> Authored: Mon Jul 10 19:30:12 2017 +0300
> Committer: DESKTOP-RH4S838\Yishay <[hidden email]>
> Committed: Mon Jul 10 19:30:12 2017 +0300
>
> ----------------------------------------------------------------------
>  .../main/flex/org/apache/flex/file/FileProxy.as |  9 ++++
>  .../flex/file/beads/FileLoaderAndUploader.as    |  2 +-
>  .../org/apache/flex/file/beads/FileUploader.as  | 18 ++++++++
>  .../file/beads/FileUploaderWithResponseData.as  | 43 ++++++++++++++++++++
>  .../src/main/resources/basic-manifest.xml       |  1 +
>  5 files changed, 72 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/FileProxy.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/FileProxy.as
> b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> index 738cf55..38c2fe8 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> @@ -23,6 +23,15 @@ package org.apache.flex.file
>         import org.apache.flex.file.beads.FileModel;
>
>         /**
> +        *  Indicates that the model has changed
> +        *
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       [Event(name="modelChanged", type="org.apache.flex.events.Event")]
> +       /**
>          *  The FileProxy class is where beads regarding file operations
> are added.
>          *  Information about operations can be queried in the file model,
> or by
>          *  listenening to events dispatched by beads.
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileLoaderAndUploader.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as b/frameworks/projects/Network/
> src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
> index 77ba96c..2b66552 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as
> @@ -21,7 +21,7 @@ package org.apache.flex.file.beads
>         import org.apache.flex.events.Event;
>
>         /**
> -        *  The FileLoaderUploader is a compound bead that allows you
> +        *  The FileLoaderAndUploader is a compound bead that allows you
>          *  to load a file and upload it in one operation.
>          *
>          *
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileUploader.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
> b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> index 0cf4d5f..470eb28 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> @@ -19,6 +19,8 @@ package org.apache.flex.file.beads
>  {
>         import org.apache.flex.core.IBead;
>         import org.apache.flex.core.IStrand;
> +       import org.apache.flex.events.Event;
> +       import org.apache.flex.events.IEventDispatcher;
>         import org.apache.flex.file.FileProxy;
>         import org.apache.flex.net.URLBinaryLoader;
>         import org.apache.flex.net.URLRequest;
> @@ -37,6 +39,15 @@ package org.apache.flex.file.beads
>         }
>
>         /**
> +        *  Indicates that the upload operation is complete
> +        *
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       [Event(name="complete", type="org.apache.flex.events.Event")]
> +       /**
>          *  The FileUploader class is a bead which adds to FileProxy
>          *  the ability to upload files.
>          *
> @@ -70,9 +81,16 @@ package org.apache.flex.file.beads
>                         var binaryUploader:URLBinaryLoader = new
> URLBinaryLoader();
>                         var req:URLRequest = new URLRequest();
>                         req.data = (host.model as FileModel).blob;
> +                       binaryUploader.addEventListener(Event.COMPLETE,
> completeHandler);
>                         binaryUploader.load(req);
>                 }
>
> +               protected function completeHandler(event:Event):void
> +               {
> +                       (event.target as IEventDispatcher).
> removeEventListener(Event.COMPLETE, completeHandler);
> +                       (host as IEventDispatcher).dispatchEvent(event);
> +               }
> +
>                 /**
>                  *  @copy org.apache.flex.core.IBead#strand
>                  *
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileUploaderWithResponseData.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploaderWithResponseData.as b/frameworks/projects/Network/
> src/main/flex/org/apache/flex/file/beads/FileUploaderWithResponseData.as
> new file mode 100644
> index 0000000..99d0b03
> --- /dev/null
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploaderWithResponseData.as
> @@ -0,0 +1,43 @@
> +//
> +//  Licensed to the Apache Software Foundation (ASF) under one or more
> +//  contributor license agreements.  See the NOTICE file distributed with
> +//  this work for additional information regarding copyright ownership.
> +//  The ASF licenses this file to You under the Apache License, Version
> 2.0
> +//  (the "License"); you may not use this file except in compliance with
> +//  the License.  You may obtain a copy of the License at
> +//
> +//      http://www.apache.org/licenses/LICENSE-2.0
> +//
> +//  Unless required by applicable law or agreed to in writing, software
> +//  distributed under the License is distributed on an "AS IS" BASIS,
> +//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +//  See the License for the specific language governing permissions and
> +//  limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package org.apache.flex.file.beads
> +{
> +       import org.apache.flex.events.Event;
> +       import org.apache.flex.net.URLBinaryLoader;
> +
> +       /**
> +        *  FileUploaderWithResponseData records responseData before
> dispatching the complete event
> +        *
> +        *
> +        *  @toplevel
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       public class FileUploaderWithResponseData extends FileUploader
> +       {
> +               public var responseData:Object;
> +
> +               override protected function completeHandler(event:Event):
> void
> +               {
> +                       responseData = (event.target as
> URLBinaryLoader).data;
> +                       super.completeHandler(event);
> +               }
> +       }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> index eabda27..4a55df4 100644
> --- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> +++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> @@ -27,5 +27,6 @@
>      <component id="FileBrowser" class="org.apache.flex.file.
> beads.FileBrowser"/>
>      <component id="FileLoader" class="org.apache.flex.file.
> beads.FileLoader"/>
>      <component id="FileUploader" class="org.apache.flex.file.
> beads.FileUploader"/>
> +    <component id="FileUploaderWithResponseData"
> class="org.apache.flex.file.beads.FileUploaderWithResponseData"/>
>      <component id="FileLoaderAndUploader" class="org.apache.flex.file.
> beads.FileLoaderAndUploader"/>
>  </componentPackage>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
I was thinking the same thing but it’s complicated to make it into a bead. It would have to catch the ‘complete’ event and record the response data before anyone else does. Since we don’t have event listener priorities I don’t know how to do that. I hope to update the wiki Greg wrote when I’m done with this. Maybe I can pass on some of my experiences.

From: Piotr Zarzycki<mailto:[hidden email]>
Sent: Monday, July 10, 2017 8:40 PM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Hi Yishay,

I'm wondering whether it is possible to have it bead instead class ? What
do you think ?

Thanks, Piotr

2017-07-10 18:30 GMT+02:00 <[hidden email]>:

> Repository: flex-asjs
> Updated Branches:
>   refs/heads/develop c6a24011b -> 54d00a044
>
>
> Add FileUploaderWithResponseData
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/54d00a04
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/54d00a04
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/54d00a04
>
> Branch: refs/heads/develop
> Commit: 54d00a044196ec62e81840b3134f9f17f26f4cb1
> Parents: c6a2401
> Author: DESKTOP-RH4S838\Yishay <[hidden email]>
> Authored: Mon Jul 10 19:30:12 2017 +0300
> Committer: DESKTOP-RH4S838\Yishay <[hidden email]>
> Committed: Mon Jul 10 19:30:12 2017 +0300
>
> ----------------------------------------------------------------------
>  .../main/flex/org/apache/flex/file/FileProxy.as |  9 ++++
>  .../flex/file/beads/FileLoaderAndUploader.as    |  2 +-
>  .../org/apache/flex/file/beads/FileUploader.as  | 18 ++++++++
>  .../file/beads/FileUploaderWithResponseData.as  | 43 ++++++++++++++++++++
>  .../src/main/resources/basic-manifest.xml       |  1 +
>  5 files changed, 72 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/FileProxy.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/FileProxy.as
> b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> index 738cf55..38c2fe8 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/FileProxy.as
> @@ -23,6 +23,15 @@ package org.apache.flex.file
>         import org.apache.flex.file.beads.FileModel;
>
>         /**
> +        *  Indicates that the model has changed
> +        *
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       [Event(name="modelChanged", type="org.apache.flex.events.Event")]
> +       /**
>          *  The FileProxy class is where beads regarding file operations
> are added.
>          *  Information about operations can be queried in the file model,
> or by
>          *  listenening to events dispatched by beads.
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileLoaderAndUploader.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as b/frameworks/projects/Network/
> src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
> index 77ba96c..2b66552 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileLoaderAndUploader.as
> @@ -21,7 +21,7 @@ package org.apache.flex.file.beads
>         import org.apache.flex.events.Event;
>
>         /**
> -        *  The FileLoaderUploader is a compound bead that allows you
> +        *  The FileLoaderAndUploader is a compound bead that allows you
>          *  to load a file and upload it in one operation.
>          *
>          *
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileUploader.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
> b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> index 0cf4d5f..470eb28 100644
> --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploader.as
> @@ -19,6 +19,8 @@ package org.apache.flex.file.beads
>  {
>         import org.apache.flex.core.IBead;
>         import org.apache.flex.core.IStrand;
> +       import org.apache.flex.events.Event;
> +       import org.apache.flex.events.IEventDispatcher;
>         import org.apache.flex.file.FileProxy;
>         import org.apache.flex.net.URLBinaryLoader;
>         import org.apache.flex.net.URLRequest;
> @@ -37,6 +39,15 @@ package org.apache.flex.file.beads
>         }
>
>         /**
> +        *  Indicates that the upload operation is complete
> +        *
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       [Event(name="complete", type="org.apache.flex.events.Event")]
> +       /**
>          *  The FileUploader class is a bead which adds to FileProxy
>          *  the ability to upload files.
>          *
> @@ -70,9 +81,16 @@ package org.apache.flex.file.beads
>                         var binaryUploader:URLBinaryLoader = new
> URLBinaryLoader();
>                         var req:URLRequest = new URLRequest();
>                         req.data = (host.model as FileModel).blob;
> +                       binaryUploader.addEventListener(Event.COMPLETE,
> completeHandler);
>                         binaryUploader.load(req);
>                 }
>
> +               protected function completeHandler(event:Event):void
> +               {
> +                       (event.target as IEventDispatcher).
> removeEventListener(Event.COMPLETE, completeHandler);
> +                       (host as IEventDispatcher).dispatchEvent(event);
> +               }
> +
>                 /**
>                  *  @copy org.apache.flex.core.IBead#strand
>                  *
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/flex/org/
> apache/flex/file/beads/FileUploaderWithResponseData.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploaderWithResponseData.as b/frameworks/projects/Network/
> src/main/flex/org/apache/flex/file/beads/FileUploaderWithResponseData.as
> new file mode 100644
> index 0000000..99d0b03
> --- /dev/null
> +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/
> file/beads/FileUploaderWithResponseData.as
> @@ -0,0 +1,43 @@
> +//
> +//  Licensed to the Apache Software Foundation (ASF) under one or more
> +//  contributor license agreements.  See the NOTICE file distributed with
> +//  this work for additional information regarding copyright ownership.
> +//  The ASF licenses this file to You under the Apache License, Version
> 2.0
> +//  (the "License"); you may not use this file except in compliance with
> +//  the License.  You may obtain a copy of the License at
> +//
> +//      http://www.apache.org/licenses/LICENSE-2.0
> +//
> +//  Unless required by applicable law or agreed to in writing, software
> +//  distributed under the License is distributed on an "AS IS" BASIS,
> +//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +//  See the License for the specific language governing permissions and
> +//  limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package org.apache.flex.file.beads
> +{
> +       import org.apache.flex.events.Event;
> +       import org.apache.flex.net.URLBinaryLoader;
> +
> +       /**
> +        *  FileUploaderWithResponseData records responseData before
> dispatching the complete event
> +        *
> +        *
> +        *  @toplevel
> +        *  @langversion 3.0
> +        *  @playerversion Flash 10.2
> +        *  @playerversion AIR 2.6
> +        *  @productversion FlexJS 0.9
> +        */
> +       public class FileUploaderWithResponseData extends FileUploader
> +       {
> +               public var responseData:Object;
> +
> +               override protected function completeHandler(event:Event):
> void
> +               {
> +                       responseData = (event.target as
> URLBinaryLoader).data;
> +                       super.completeHandler(event);
> +               }
> +       }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 54d00a04/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> index eabda27..4a55df4 100644
> --- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> +++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
> @@ -27,5 +27,6 @@
>      <component id="FileBrowser" class="org.apache.flex.file.
> beads.FileBrowser"/>
>      <component id="FileLoader" class="org.apache.flex.file.
> beads.FileLoader"/>
>      <component id="FileUploader" class="org.apache.flex.file.
> beads.FileUploader"/>
> +    <component id="FileUploaderWithResponseData"
> class="org.apache.flex.file.beads.FileUploaderWithResponseData"/>
>      <component id="FileLoaderAndUploader" class="org.apache.flex.file.
> beads.FileLoaderAndUploader"/>
>  </componentPackage>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
Since this type of problem has been bugging me for a while (see also FileBrowserWithFilter which raises the same question) I started reading about this. To me it seems that we may need aspects [1]. The JS implementation is supposed to be easy, but AS3 less so [2], though work has been done [3] on this.

Any thoughts?

[1] https://en.wikipedia.org/wiki/Aspect-oriented_programming
[2] https://stackoverflow.com/questions/5440073/re-defining-named-functions-at-runtime
[3] https://www.slideshare.net/jlward4th/planet-of-the-aops
Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Alex Harui-2
What problem are you referring to?

-Alex

On 7/11/17, 7:03 PM, "yishayw" <[hidden email]> wrote:

>Since this type of problem has been bugging me for a while (see also
>FileBrowserWithFilter which raises the same question) I started reading
>about this. To me it seems that we may need aspects [1]. The JS
>implementation is supposed to be easy, but AS3 less so [2], though work
>has
>been done [3] on this.
>
>Any thoughts?
>
>[1]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipe
>dia.org%2Fwiki%2FAspect-oriented_programming&data=02%7C01%7C%7Ca9962092b3e
>3430bd2cf08d4c8cce2c5%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6363542
>29688028624&sdata=PAo4%2FdNps18%2FsjzdWVPNWGlCpMSUNtW1NU0r%2B5Lb79A%3D&res
>erved=0
>[2]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackover
>flow.com%2Fquestions%2F5440073%2Fre-defining-named-functions-at-runtime&da
>ta=02%7C01%7C%7Ca9962092b3e3430bd2cf08d4c8cce2c5%7Cfa7b1b5a7b34438794aed2c
>178decee1%7C0%7C0%7C636354229688038633&sdata=X6GrZnR0GcblhMMGgScvpAV%2BQHr
>ZO6eqqbxfl0I1suU%3D&reserved=0
>[3]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.slide
>share.net%2Fjlward4th%2Fplanet-of-the-aops&data=02%7C01%7C%7Ca9962092b3e34
>30bd2cf08d4c8cce2c5%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636354229
>688038633&sdata=VYq1gio%2BYxX0ln5xACtxAyghPD77nIBHYlnhp0kv6f8%3D&reserved=
>0
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-d
>evelop-Add-FileUploaderWithResponseData-tp63051p63131.html&data=02%7C01%7C
>%7Ca9962092b3e3430bd2cf08d4c8cce2c5%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636354229688038633&sdata=QiD5%2FBAcCIu4SMLPh%2BDrIMldJUoEh10K%2BrXw
>HBLf3%2Bs%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
See upthread my response to Pitor

I was thinking the same thing but it’s complicated to make it into a bead. It would have to catch the ‘complete’ event and record the response data before anyone else does. Since we don’t have event listener priorities I don’t know how to do that. I hope to update the wiki Greg wrote when I’m done with this. Maybe I can pass on some of my experiences.
Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Alex Harui-2
I guess I still don't understand.

Is the goal to expose the responseData?  Why does the bead need to record
the response data?  Why can't it just get it when someone asks for it?

I'm by no means an expert on Aspects.  I think beads should be able to do
some of what I understand aspects do without modifying the class
definition.  If the strand doesn't hide stuff from the beads (by storing
data in a model) beads should have access to enough stuff from the strand,
and thus additional beads can expose that data.

Thanks,
-Alex

On 7/11/17, 10:28 PM, "yishayw" <[hidden email]> wrote:

>See upthread my response to Pitor
>
>
>> I was thinking the same thing but it’s complicated to make it into a
>>bead.
>> It would have to catch the ‘complete’ event and record the response data
>> before anyone else does. Since we don’t have event listener priorities I
>> don’t know how to do that. I hope to update the wiki Greg wrote when I’m
>> done with this. Maybe I can pass on some of my experiences.
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-d
>evelop-Add-FileUploaderWithResponseData-tp63051p63136.html&data=02%7C01%7C
>%7Cd06b2ce9fd704a05c4a508d4c8e98cbd%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636354352800533854&sdata=9agjvr89lTGBZB7RzDDMA6S4A3cGd0CGSowI9T7Gb8
>k%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
Ideally we wouldn't have to record data that's never read. This may be an extreme case, but some users will want to know the response on an upload, while some will just want to make sure the status is ok. I'd rather not anticipate too many use cases when writing the strand and the model because I might end up with code that's never used. If the bead was responsible for both recording the response and exposing it to the user, we wouldn't have to do that.

Perhaps a better example is permissions. I already have an Upload bead. Now I want an alert to pop up if the user is not permitted to upload. I'd like to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't see how to do that, instead I would probably have to replace 'UploadBead' with 'UploadButCheckPermissionsBead'. This takes us away from composition and forces inheritance.

Maybe we don't need to modify class definitions. I think it's enough to modify the bead instance. In JS we could simply replace the function, and in flash we could maybe replace the whole original bead with a flash.utils.Proxy. But this will make things a bit complicated to read and maintain.

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Alex Harui-2
I think I still don't understand.

It is ok for beads to require other beads.  If a ResponseData bead
requires a model with a slot for responseData and a controller that knows
to record that data, that's how you are supposed to "re-compose"
components.  There doesn't have to be one model or controller per
component.  The strand is a gathering place for small pieces to work
together.

I'm not sure what work CheckPermissions needs to do, but is totally fine
to split its work amongst a set of beads.

HTH,
-Alex

On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:

>Ideally we wouldn't have to record data that's never read. This may be an
>extreme case, but some users will want to know the response on an upload,
>while some will just want to make sure the status is ok. I'd rather not
>anticipate too many use cases when writing the strand and the model
>because
>I might end up with code that's never used. If the bead was responsible
>for
>both recording the response and exposing it to the user, we wouldn't have
>to
>do that.
>
>Perhaps a better example is permissions. I already have an Upload bead.
>Now
>I want an alert to pop up if the user is not permitted to upload. I'd like
>to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't see
>how to do that, instead I would probably have to replace 'UploadBead' with
>'UploadButCheckPermissionsBead'. This takes us away from composition and
>forces inheritance.
>
>Maybe we don't need to modify class definitions. I think it's enough to
>modify the bead instance. In JS we could simply replace the function, and
>in
>flash we could maybe replace the whole original bead with a
>flash.utils.Proxy. But this will make things a bit complicated to read and
>maintain.
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-d
>evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01%7C
>%7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2BlaF6d
>v8w%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
Generally speaking it feels like sometimes I need to insure the order of invocation. Since beads communicate with one another through events it’s difficult to achieve. Regarding the upload response data I understand your suggestion as follows (edges contain event names):

<Strand>--uploadRequested--<controllerForWithResponse (sends request)>---complete---<ModelWithResponse (after controller wrote to model>---modelChanged--<UserClassListening>

And for the case where the user isn’t interested in the response, just in the status:

<Strand>---uploadRequested--<controllerForWithoutResponse>---complete---<ModelWithoutResponse>--modelChanged--<UserClassListening>

Is that right?


From: Alex Harui<mailto:[hidden email]>
Sent: Wednesday, July 12, 2017 9:58 AM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

I think I still don't understand.

It is ok for beads to require other beads.  If a ResponseData bead
requires a model with a slot for responseData and a controller that knows
to record that data, that's how you are supposed to "re-compose"
components.  There doesn't have to be one model or controller per
component.  The strand is a gathering place for small pieces to work
together.

I'm not sure what work CheckPermissions needs to do, but is totally fine
to split its work amongst a set of beads.

HTH,
-Alex

On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:

>Ideally we wouldn't have to record data that's never read. This may be an
>extreme case, but some users will want to know the response on an upload,
>while some will just want to make sure the status is ok. I'd rather not
>anticipate too many use cases when writing the strand and the model
>because
>I might end up with code that's never used. If the bead was responsible
>for
>both recording the response and exposing it to the user, we wouldn't have
>to
>do that.
>
>Perhaps a better example is permissions. I already have an Upload bead.
>Now
>I want an alert to pop up if the user is not permitted to upload. I'd like
>to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't see
>how to do that, instead I would probably have to replace 'UploadBead' with
>'UploadButCheckPermissionsBead'. This takes us away from composition and
>forces inheritance.
>
>Maybe we don't need to modify class definitions. I think it's enough to
>modify the bead instance. In JS we could simply replace the function, and
>in
>flash we could maybe replace the whole original bead with a
>flash.utils.Proxy. But this will make things a bit complicated to read and
>maintain.
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-d
>evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01%7C
>%7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2BlaF6d
>v8w%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Alex Harui-2
Yes, that's how I think of it.  You are right that getting one bead in a
multi bead set to listen to other beads is tricky.  UIBase defines a
particular order of model first, then view, then controller.  But
otherwise, you either have to dictate your own order or find another event
to listen to that will give a bead another chance to search the strand for
other beads to listen to.  There is a "beadsAdded" event that can be used.

Maybe as more folks implement multi-bead sets we'll see patterns emerge
and make it is simpler and faster.

My 2 cents,
-Alex

On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:

>Generally speaking it feels like sometimes I need to insure the order of
>invocation. Since beads communicate with one another through events it’s
>difficult to achieve. Regarding the upload response data I understand
>your suggestion as follows (edges contain event names):
>
><Strand>--uploadRequested--<controllerForWithResponse (sends
>request)>---complete---<ModelWithResponse (after controller wrote to
>model>---modelChanged--<UserClassListening>
>
>And for the case where the user isn’t interested in the response, just in
>the status:
>
><Strand>---uploadRequested--<controllerForWithoutResponse>---complete---<M
>odelWithoutResponse>--modelChanged--<UserClassListening>
>
>Is that right?
>
>
>From: Alex Harui<mailto:[hidden email]>
>Sent: Wednesday, July 12, 2017 9:58 AM
>To: [hidden email]<mailto:[hidden email]>
>Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>FileUploaderWithResponseData
>
>I think I still don't understand.
>
>It is ok for beads to require other beads.  If a ResponseData bead
>requires a model with a slot for responseData and a controller that knows
>to record that data, that's how you are supposed to "re-compose"
>components.  There doesn't have to be one model or controller per
>component.  The strand is a gathering place for small pieces to work
>together.
>
>I'm not sure what work CheckPermissions needs to do, but is totally fine
>to split its work amongst a set of beads.
>
>HTH,
>-Alex
>
>On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>
>>Ideally we wouldn't have to record data that's never read. This may be an
>>extreme case, but some users will want to know the response on an upload,
>>while some will just want to make sure the status is ok. I'd rather not
>>anticipate too many use cases when writing the strand and the model
>>because
>>I might end up with code that's never used. If the bead was responsible
>>for
>>both recording the response and exposing it to the user, we wouldn't have
>>to
>>do that.
>>
>>Perhaps a better example is permissions. I already have an Upload bead.
>>Now
>>I want an alert to pop up if the user is not permitted to upload. I'd
>>like
>>to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't see
>>how to do that, instead I would probably have to replace 'UploadBead'
>>with
>>'UploadButCheckPermissionsBead'. This takes us away from composition and
>>forces inheritance.
>>
>>Maybe we don't need to modify class definitions. I think it's enough to
>>modify the bead instance. In JS we could simply replace the function, and
>>in
>>flash we could maybe replace the whole original bead with a
>>flash.utils.Proxy. But this will make things a bit complicated to read
>>and
>>maintain.
>>
>>
>>
>>
>>
>>--
>>View this message in context:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fl
>>e
>>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-
>>d
>>evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01%7
>>C
>>%7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%7C
>>0
>>%7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2BlaF6
>>d
>>v8w%3D&reserved=0
>>Sent from the Apache Flex Development mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

yishayw
So going back to Piotr's original post, the current approach for adding functionality to a bead (ControllerForWithoutResponse) is to create a new bead (ConterollerForWithResponse) that extends the functionality of the original bead, rather than adding a bead to the original one (ControllerForResponse + ControllerForWithoutResponse).

This is what I meant when I said we're being forced out of composition into inheritance.
Reply | Threaded
Open this post in threaded view
|

Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Harbs
In reply to this post by Alex Harui-2
Now that Yishay and I have spent quite some time with beads, I have some thoughts on the architecture.

Here’s some things I’ve noticed (somewhat randomly):

1. There’s no clear place to add beads to components in AS. It seems like the catch-all place to do so is in addedToParent(), but many components add beads at other places. Many of these are lazy initialization and the like. There’s probably good reasons for all of these, but it’s confusing. Here’s a list of places where addBead() is called in Basic:
start
initHandler
finishSetup
set states
get/set model
get/set view
get measurementBead
setCursor
get accordionCollapseBead
get layout
set strand
createViewport
createLists
displayBackgroundAndBorder
setupForBorder
handleMessageChange
get presentationModel
constructor

Especially for someone who is new to this, it’s very confusing to know where the right place to add a bead is.

2. It’s not immediately obvious that Beads can also be Strands. There are quite a few cases where that’s true. The only ones I’ve noticed were View Beads.

3. It’s hard to follow which beads have which dependencies. There are event listeners added at seemingly random places and events dispatched seemingly randomly as well. It’s hard to follow the flow.

4. It’s hard to know when beads are added and in what order.

5. Even if you know what other beads and events your bead relies on, you need to cross-reference to know what exact events are being dispatched.

6. The use of events is probably overkill for the needs of stands and beads. Strands are effectively a command bus for the beads (there’s many terms for the same concept). Events have significant overhead and indirection. Really what we need is for beads to tell the Strand “hey, I need to know when x happens so I can react and/or change what’s happening” and when beads do things they need to say “hey here’s what I did/ want to do”.

7. Beads have no way of knowing when they can finish setting up. The only way to do so is attach event listeners which is a bit awkward.

I really like the Notification architecture in PureMVC, and I think it’s perfect for Strands and Beads.

Without going into all the nitty gritty details, the classes have some standard info that the “mediator” can use to find who’s interested in what. The classes which need to react to specific notifications (i.e. Mediators) list their interests and they are directly notified when something that interests them happened.

There’s also a clear lifecycle where functions can be called at predetermined times. Notification is done by using a Notification object which has three properties: name, type and body. Subscription to events happens through their names, but Notifications of the same name can modify their behavior by their type. body is an Object and can contain any kind of payload.

I’d like to see a couple of things with Strands and Beads.

1. We should publish popular patterns for Strand/Bead interaction. (I’m talking to myself as much as anyone else.)

2. I’d like to have a clearly documented lifecycle for beads. There are some standard bead types such as Model, Controller, View, Content View. When should each of these be created and how? At critical points in this cycle, things should happen automatically: The strand should pull from each bead which is added what interests it has.

3. At the point when all “necessary” beads are added, the beads should have some method automatically called so they can “finish” their setup if they rely on another bead.

4. All Strands should have a “notify” method that beads can call to let the strand know to let the appropriate beads know about an event. The beads should send a notification with the necessary payload if one is needed. Other beads can modify this payload and/or change the notification type if necessary. The publisher of the notification can examine the notification after it’s sent to know if it needs to do something different.

Bonus points if there’s some kind of “post process” on notifications in case a bead needs to wait until after some other bead did their thing. This can take the form of a “registerPostProcess” call to the bead which is only every called once per registration.

5. I’m likely missing some points in the lifecycle…

This is something that I’d work on if others think this makes any kind of sense. While a lot of this is not very different from how events are working today, it feels to me like it would help give the strand/bead relationships a lot more structure.

Thoughts?
Harbs

>
> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]> wrote:
>
> Yes, that's how I think of it.  You are right that getting one bead in a
> multi bead set to listen to other beads is tricky.  UIBase defines a
> particular order of model first, then view, then controller.  But
> otherwise, you either have to dictate your own order or find another event
> to listen to that will give a bead another chance to search the strand for
> other beads to listen to.  There is a "beadsAdded" event that can be used.
>
> Maybe as more folks implement multi-bead sets we'll see patterns emerge
> and make it is simpler and faster.
>
> My 2 cents,
> -Alex
>
> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>
>> Generally speaking it feels like sometimes I need to insure the order of
>> invocation. Since beads communicate with one another through events it’s
>> difficult to achieve. Regarding the upload response data I understand
>> your suggestion as follows (edges contain event names):
>>
>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>> request)>---complete---<ModelWithResponse (after controller wrote to
>> model>---modelChanged--<UserClassListening>
>>
>> And for the case where the user isn’t interested in the response, just in
>> the status:
>>
>> <Strand>---uploadRequested--<controllerForWithoutResponse>---complete---<M
>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>
>> Is that right?
>>
>>
>> From: Alex Harui<mailto:[hidden email]>
>> Sent: Wednesday, July 12, 2017 9:58 AM
>> To: [hidden email]<mailto:[hidden email]>
>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>> FileUploaderWithResponseData
>>
>> I think I still don't understand.
>>
>> It is ok for beads to require other beads.  If a ResponseData bead
>> requires a model with a slot for responseData and a controller that knows
>> to record that data, that's how you are supposed to "re-compose"
>> components.  There doesn't have to be one model or controller per
>> component.  The strand is a gathering place for small pieces to work
>> together.
>>
>> I'm not sure what work CheckPermissions needs to do, but is totally fine
>> to split its work amongst a set of beads.
>>
>> HTH,
>> -Alex
>>
>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>
>>> Ideally we wouldn't have to record data that's never read. This may be an
>>> extreme case, but some users will want to know the response on an upload,
>>> while some will just want to make sure the status is ok. I'd rather not
>>> anticipate too many use cases when writing the strand and the model
>>> because
>>> I might end up with code that's never used. If the bead was responsible
>>> for
>>> both recording the response and exposing it to the user, we wouldn't have
>>> to
>>> do that.
>>>
>>> Perhaps a better example is permissions. I already have an Upload bead.
>>> Now
>>> I want an alert to pop up if the user is not permitted to upload. I'd
>>> like
>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't see
>>> how to do that, instead I would probably have to replace 'UploadBead'
>>> with
>>> 'UploadButCheckPermissionsBead'. This takes us away from composition and
>>> forces inheritance.
>>>
>>> Maybe we don't need to modify class definitions. I think it's enough to
>>> modify the bead instance. In JS we could simply replace the function, and
>>> in
>>> flash we could maybe replace the whole original bead with a
>>> flash.utils.Proxy. But this will make things a bit complicated to read
>>> and
>>> maintain.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fl
>>> e
>>> x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-heads-
>>> d
>>> evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01%7
>>> C
>>> %7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%7C
>>> 0
>>> %7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2BlaF6
>>> d
>>> v8w%3D&reserved=0
>>> Sent from the Apache Flex Development mailing list archive at Nabble.com.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

piotrz
Harbs,

I agree with everything what you just said. I've used PureMVC a lot and indeed it has really strong communication channel between each parts of framework which is worth to apply if it possible.

Apart of that I think your experience should be put at least as an comments to page about PAYG which Greg started.

Thank you with sharing with us all of that!
Piotr
Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Alex Harui-2
In reply to this post by Harbs
These are good points.  I'm glad I sent my PAYG email earlier today.  I'm
not sure I understood points #3 (dependencies) and #5 (cross-referencing)
so apologies if my thoughts below didn't take them into account.

I'd say that some of these ideas simply need to be tried and measured
against the PAYG metrics I proposed.  For example:
1) Can we implement a second, lighterweight notification system without
increasing download size?  Besides mediators I think there is another
mechanism called AS3Signals.
2) Can we have more consistency in when beads get instantiated or will
that cause too many beads to be instantiated "just-in-case"?  It may just
be that "just-in-time" or "lazy" instantiation of beads is going to make
it hard to know when a bead will be added to the strand, but I think
"just-in-time" instantiation is always going to provide best performance.
Too much consistency sometimes results in too much just-in-case code.
3) Is it better to require certain beads to be placed on the strand before
other beads?  Does doing so make the code smaller or faster?  Will it be
more painful for developers to get the order right?  It might be best just
to find the best patterns for waiting for your partner beads.  One thing
to consider is that we have more control over when beads get added in
MXML, but we probably shouldn't have control over when beads get added in
AS.  I don't think the compiler can or should detect when the application
developer is going to add a bead and tell them not to do it.

There are probably at least two different "lifecycles".  Any individual
bead's lifecycle should be pretty simple: Instantiation, Initial
Properties, Add To Strand, Listen for Events/Notifications/Property
Changes.  Depending on how we decide #3 above, some beads may have a "wait
for my partner bead" phase.
A UI Component has a lifecycle of: Instantiation, Initial Properties, Add
To Parent, Add Beads.  But model beads may be instantiated and added on
demand in Initial Properties.  In "Add Beads" the model is added first if
not already added, then the view, then everything else.  In theory, the
"beadsAdded" event can be used by beads to know when significant changes
to the set of beads has occurred and that can be used to finish setting up
if you are waiting for partner beads, but otherwise, I think you can count
on model being instantiated on-demand and finish up in your strand setter.

The idea I liked the least was the notion that the Strand was some
intermediary and beads talk to the Strand, tell the Strand what their
interest are and things like that.  In my view the strand is just a bus
like you mentioned and isn't involved in any communications.  The beads
simply use the bus to find each other and find the most PAYG way of
communicating.  

Have you found common/popular patterns?  I don't really know because I've
been spending most of my time in the compiler.  If you have, then yes,
please document them.

My 2 cents,
-Alex

On 7/13/17, 3:40 PM, "Harbs" <[hidden email]> wrote:

>Now that Yishay and I have spent quite some time with beads, I have some
>thoughts on the architecture.
>
>Here’s some things I’ve noticed (somewhat randomly):
>
>1. There’s no clear place to add beads to components in AS. It seems like
>the catch-all place to do so is in addedToParent(), but many components
>add beads at other places. Many of these are lazy initialization and the
>like. There’s probably good reasons for all of these, but it’s confusing.
>Here’s a list of places where addBead() is called in Basic:
>start
>initHandler
>finishSetup
>set states
>get/set model
>get/set view
>get measurementBead
>setCursor
>get accordionCollapseBead
>get layout
>set strand
>createViewport
>createLists
>displayBackgroundAndBorder
>setupForBorder
>handleMessageChange
>get presentationModel
>constructor
>
>Especially for someone who is new to this, it’s very confusing to know
>where the right place to add a bead is.
>
>2. It’s not immediately obvious that Beads can also be Strands. There are
>quite a few cases where that’s true. The only ones I’ve noticed were View
>Beads.
>
>3. It’s hard to follow which beads have which dependencies. There are
>event listeners added at seemingly random places and events dispatched
>seemingly randomly as well. It’s hard to follow the flow.
>
>4. It’s hard to know when beads are added and in what order.
>
>5. Even if you know what other beads and events your bead relies on, you
>need to cross-reference to know what exact events are being dispatched.
>
>6. The use of events is probably overkill for the needs of stands and
>beads. Strands are effectively a command bus for the beads (there’s many
>terms for the same concept). Events have significant overhead and
>indirection. Really what we need is for beads to tell the Strand “hey, I
>need to know when x happens so I can react and/or change what’s
>happening” and when beads do things they need to say “hey here’s what I
>did/ want to do”.
>
>7. Beads have no way of knowing when they can finish setting up. The only
>way to do so is attach event listeners which is a bit awkward.
>
>I really like the Notification architecture in PureMVC, and I think it’s
>perfect for Strands and Beads.
>
>Without going into all the nitty gritty details, the classes have some
>standard info that the “mediator” can use to find who’s interested in
>what. The classes which need to react to specific notifications (i.e.
>Mediators) list their interests and they are directly notified when
>something that interests them happened.
>
>There’s also a clear lifecycle where functions can be called at
>predetermined times. Notification is done by using a Notification object
>which has three properties: name, type and body. Subscription to events
>happens through their names, but Notifications of the same name can
>modify their behavior by their type. body is an Object and can contain
>any kind of payload.
>
>I’d like to see a couple of things with Strands and Beads.
>
>1. We should publish popular patterns for Strand/Bead interaction. (I’m
>talking to myself as much as anyone else.)
>
>2. I’d like to have a clearly documented lifecycle for beads. There are
>some standard bead types such as Model, Controller, View, Content View.
>When should each of these be created and how? At critical points in this
>cycle, things should happen automatically: The strand should pull from
>each bead which is added what interests it has.
>
>3. At the point when all “necessary” beads are added, the beads should
>have some method automatically called so they can “finish” their setup if
>they rely on another bead.
>
>4. All Strands should have a “notify” method that beads can call to let
>the strand know to let the appropriate beads know about an event. The
>beads should send a notification with the necessary payload if one is
>needed. Other beads can modify this payload and/or change the
>notification type if necessary. The publisher of the notification can
>examine the notification after it’s sent to know if it needs to do
>something different.
>
>Bonus points if there’s some kind of “post process” on notifications in
>case a bead needs to wait until after some other bead did their thing.
>This can take the form of a “registerPostProcess” call to the bead which
>is only every called once per registration.
>
>5. I’m likely missing some points in the lifecycle…
>
>This is something that I’d work on if others think this makes any kind of
>sense. While a lot of this is not very different from how events are
>working today, it feels to me like it would help give the strand/bead
>relationships a lot more structure.
>
>Thoughts?
>Harbs
>
>>
>> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]>
>>wrote:
>>
>> Yes, that's how I think of it.  You are right that getting one bead in a
>> multi bead set to listen to other beads is tricky.  UIBase defines a
>> particular order of model first, then view, then controller.  But
>> otherwise, you either have to dictate your own order or find another
>>event
>> to listen to that will give a bead another chance to search the strand
>>for
>> other beads to listen to.  There is a "beadsAdded" event that can be
>>used.
>>
>> Maybe as more folks implement multi-bead sets we'll see patterns emerge
>> and make it is simpler and faster.
>>
>> My 2 cents,
>> -Alex
>>
>> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>>
>>> Generally speaking it feels like sometimes I need to insure the order
>>>of
>>> invocation. Since beads communicate with one another through events
>>>it’s
>>> difficult to achieve. Regarding the upload response data I understand
>>> your suggestion as follows (edges contain event names):
>>>
>>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>>> request)>---complete---<ModelWithResponse (after controller wrote to
>>> model>---modelChanged--<UserClassListening>
>>>
>>> And for the case where the user isn’t interested in the response, just
>>>in
>>> the status:
>>>
>>>
>>><Strand>---uploadRequested--<controllerForWithoutResponse>---complete---
>>><M
>>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>>
>>> Is that right?
>>>
>>>
>>> From: Alex Harui<mailto:[hidden email]>
>>> Sent: Wednesday, July 12, 2017 9:58 AM
>>> To: [hidden email]<mailto:[hidden email]>
>>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>>> FileUploaderWithResponseData
>>>
>>> I think I still don't understand.
>>>
>>> It is ok for beads to require other beads.  If a ResponseData bead
>>> requires a model with a slot for responseData and a controller that
>>>knows
>>> to record that data, that's how you are supposed to "re-compose"
>>> components.  There doesn't have to be one model or controller per
>>> component.  The strand is a gathering place for small pieces to work
>>> together.
>>>
>>> I'm not sure what work CheckPermissions needs to do, but is totally
>>>fine
>>> to split its work amongst a set of beads.
>>>
>>> HTH,
>>> -Alex
>>>
>>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>>
>>>> Ideally we wouldn't have to record data that's never read. This may
>>>>be an
>>>> extreme case, but some users will want to know the response on an
>>>>upload,
>>>> while some will just want to make sure the status is ok. I'd rather
>>>>not
>>>> anticipate too many use cases when writing the strand and the model
>>>> because
>>>> I might end up with code that's never used. If the bead was
>>>>responsible
>>>> for
>>>> both recording the response and exposing it to the user, we wouldn't
>>>>have
>>>> to
>>>> do that.
>>>>
>>>> Perhaps a better example is permissions. I already have an Upload
>>>>bead.
>>>> Now
>>>> I want an alert to pop up if the user is not permitted to upload. I'd
>>>> like
>>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't
>>>>see
>>>> how to do that, instead I would probably have to replace 'UploadBead'
>>>> with
>>>> 'UploadButCheckPermissionsBead'. This takes us away from composition
>>>>and
>>>> forces inheritance.
>>>>
>>>> Maybe we don't need to modify class definitions. I think it's enough
>>>>to
>>>> modify the bead instance. In JS we could simply replace the function,
>>>>and
>>>> in
>>>> flash we could maybe replace the whole original bead with a
>>>> flash.utils.Proxy. But this will make things a bit complicated to read
>>>> and
>>>> maintain.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-
>>>>fl
>>>> e
>>>>
>>>>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-head
>>>>s-
>>>> d
>>>>
>>>>evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01
>>>>%7
>>>> C
>>>>
>>>>%7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%
>>>>7C
>>>> 0
>>>>
>>>>%7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2Bla
>>>>F6
>>>> d
>>>> v8w%3D&reserved=0
>>>> Sent from the Apache Flex Development mailing list archive at
>>>>Nabble.com.
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Harbs
1. I think so, or at most, only slightly. We’d probably save some code by not adding lots of functions for events and the like. I feel like the event system in general is bloated more than it needs to be.
2. I think there’s probably some and some. There’s probably going to be some lazy beads, and that’s ok. The way I see it is that there are two kinds of beads. There’s required ones which are not lazy and then there’s possibly-required, lazy ones. Lazy ones by definition will not need to listen for every notification. As long as there’s structure for the required ones, it’s good.
3. I think it’s okay to require certain classes of beads to be loaded in a certain order (i.e. controllers and views), as long as it doesn’t lead to pitfall bugs, but there’s probably others where requiring the order makes things difficult.

Totally agree about the compiler bit.

I generally think better by doing rather than writing.

What I might do when I have some spare time is to do some experiments on a branch and see what happens. I have no problem if my experiments turn out to be pointless. Either way, it should be educational. I think it would give a concrete point of reference.

Harbs

> On Jul 14, 2017, at 2:48 AM, Alex Harui <[hidden email]> wrote:
>
> These are good points.  I'm glad I sent my PAYG email earlier today.  I'm
> not sure I understood points #3 (dependencies) and #5 (cross-referencing)
> so apologies if my thoughts below didn't take them into account.
>
> I'd say that some of these ideas simply need to be tried and measured
> against the PAYG metrics I proposed.  For example:
> 1) Can we implement a second, lighterweight notification system without
> increasing download size?  Besides mediators I think there is another
> mechanism called AS3Signals.
> 2) Can we have more consistency in when beads get instantiated or will
> that cause too many beads to be instantiated "just-in-case"?  It may just
> be that "just-in-time" or "lazy" instantiation of beads is going to make
> it hard to know when a bead will be added to the strand, but I think
> "just-in-time" instantiation is always going to provide best performance.
> Too much consistency sometimes results in too much just-in-case code.
> 3) Is it better to require certain beads to be placed on the strand before
> other beads?  Does doing so make the code smaller or faster?  Will it be
> more painful for developers to get the order right?  It might be best just
> to find the best patterns for waiting for your partner beads.  One thing
> to consider is that we have more control over when beads get added in
> MXML, but we probably shouldn't have control over when beads get added in
> AS.  I don't think the compiler can or should detect when the application
> developer is going to add a bead and tell them not to do it.
>
> There are probably at least two different "lifecycles".  Any individual
> bead's lifecycle should be pretty simple: Instantiation, Initial
> Properties, Add To Strand, Listen for Events/Notifications/Property
> Changes.  Depending on how we decide #3 above, some beads may have a "wait
> for my partner bead" phase.
> A UI Component has a lifecycle of: Instantiation, Initial Properties, Add
> To Parent, Add Beads.  But model beads may be instantiated and added on
> demand in Initial Properties.  In "Add Beads" the model is added first if
> not already added, then the view, then everything else.  In theory, the
> "beadsAdded" event can be used by beads to know when significant changes
> to the set of beads has occurred and that can be used to finish setting up
> if you are waiting for partner beads, but otherwise, I think you can count
> on model being instantiated on-demand and finish up in your strand setter.
>
> The idea I liked the least was the notion that the Strand was some
> intermediary and beads talk to the Strand, tell the Strand what their
> interest are and things like that.  In my view the strand is just a bus
> like you mentioned and isn't involved in any communications.  The beads
> simply use the bus to find each other and find the most PAYG way of
> communicating.  
>
> Have you found common/popular patterns?  I don't really know because I've
> been spending most of my time in the compiler.  If you have, then yes,
> please document them.
>
> My 2 cents,
> -Alex
>
> On 7/13/17, 3:40 PM, "Harbs" <[hidden email]> wrote:
>
>> Now that Yishay and I have spent quite some time with beads, I have some
>> thoughts on the architecture.
>>
>> Here’s some things I’ve noticed (somewhat randomly):
>>
>> 1. There’s no clear place to add beads to components in AS. It seems like
>> the catch-all place to do so is in addedToParent(), but many components
>> add beads at other places. Many of these are lazy initialization and the
>> like. There’s probably good reasons for all of these, but it’s confusing.
>> Here’s a list of places where addBead() is called in Basic:
>> start
>> initHandler
>> finishSetup
>> set states
>> get/set model
>> get/set view
>> get measurementBead
>> setCursor
>> get accordionCollapseBead
>> get layout
>> set strand
>> createViewport
>> createLists
>> displayBackgroundAndBorder
>> setupForBorder
>> handleMessageChange
>> get presentationModel
>> constructor
>>
>> Especially for someone who is new to this, it’s very confusing to know
>> where the right place to add a bead is.
>>
>> 2. It’s not immediately obvious that Beads can also be Strands. There are
>> quite a few cases where that’s true. The only ones I’ve noticed were View
>> Beads.
>>
>> 3. It’s hard to follow which beads have which dependencies. There are
>> event listeners added at seemingly random places and events dispatched
>> seemingly randomly as well. It’s hard to follow the flow.
>>
>> 4. It’s hard to know when beads are added and in what order.
>>
>> 5. Even if you know what other beads and events your bead relies on, you
>> need to cross-reference to know what exact events are being dispatched.
>>
>> 6. The use of events is probably overkill for the needs of stands and
>> beads. Strands are effectively a command bus for the beads (there’s many
>> terms for the same concept). Events have significant overhead and
>> indirection. Really what we need is for beads to tell the Strand “hey, I
>> need to know when x happens so I can react and/or change what’s
>> happening” and when beads do things they need to say “hey here’s what I
>> did/ want to do”.
>>
>> 7. Beads have no way of knowing when they can finish setting up. The only
>> way to do so is attach event listeners which is a bit awkward.
>>
>> I really like the Notification architecture in PureMVC, and I think it’s
>> perfect for Strands and Beads.
>>
>> Without going into all the nitty gritty details, the classes have some
>> standard info that the “mediator” can use to find who’s interested in
>> what. The classes which need to react to specific notifications (i.e.
>> Mediators) list their interests and they are directly notified when
>> something that interests them happened.
>>
>> There’s also a clear lifecycle where functions can be called at
>> predetermined times. Notification is done by using a Notification object
>> which has three properties: name, type and body. Subscription to events
>> happens through their names, but Notifications of the same name can
>> modify their behavior by their type. body is an Object and can contain
>> any kind of payload.
>>
>> I’d like to see a couple of things with Strands and Beads.
>>
>> 1. We should publish popular patterns for Strand/Bead interaction. (I’m
>> talking to myself as much as anyone else.)
>>
>> 2. I’d like to have a clearly documented lifecycle for beads. There are
>> some standard bead types such as Model, Controller, View, Content View.
>> When should each of these be created and how? At critical points in this
>> cycle, things should happen automatically: The strand should pull from
>> each bead which is added what interests it has.
>>
>> 3. At the point when all “necessary” beads are added, the beads should
>> have some method automatically called so they can “finish” their setup if
>> they rely on another bead.
>>
>> 4. All Strands should have a “notify” method that beads can call to let
>> the strand know to let the appropriate beads know about an event. The
>> beads should send a notification with the necessary payload if one is
>> needed. Other beads can modify this payload and/or change the
>> notification type if necessary. The publisher of the notification can
>> examine the notification after it’s sent to know if it needs to do
>> something different.
>>
>> Bonus points if there’s some kind of “post process” on notifications in
>> case a bead needs to wait until after some other bead did their thing.
>> This can take the form of a “registerPostProcess” call to the bead which
>> is only every called once per registration.
>>
>> 5. I’m likely missing some points in the lifecycle…
>>
>> This is something that I’d work on if others think this makes any kind of
>> sense. While a lot of this is not very different from how events are
>> working today, it feels to me like it would help give the strand/bead
>> relationships a lot more structure.
>>
>> Thoughts?
>> Harbs
>>
>>>
>>> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]>
>>> wrote:
>>>
>>> Yes, that's how I think of it.  You are right that getting one bead in a
>>> multi bead set to listen to other beads is tricky.  UIBase defines a
>>> particular order of model first, then view, then controller.  But
>>> otherwise, you either have to dictate your own order or find another
>>> event
>>> to listen to that will give a bead another chance to search the strand
>>> for
>>> other beads to listen to.  There is a "beadsAdded" event that can be
>>> used.
>>>
>>> Maybe as more folks implement multi-bead sets we'll see patterns emerge
>>> and make it is simpler and faster.
>>>
>>> My 2 cents,
>>> -Alex
>>>
>>> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>>>
>>>> Generally speaking it feels like sometimes I need to insure the order
>>>> of
>>>> invocation. Since beads communicate with one another through events
>>>> it’s
>>>> difficult to achieve. Regarding the upload response data I understand
>>>> your suggestion as follows (edges contain event names):
>>>>
>>>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>>>> request)>---complete---<ModelWithResponse (after controller wrote to
>>>> model>---modelChanged--<UserClassListening>
>>>>
>>>> And for the case where the user isn’t interested in the response, just
>>>> in
>>>> the status:
>>>>
>>>>
>>>> <Strand>---uploadRequested--<controllerForWithoutResponse>---complete---
>>>> <M
>>>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>>>
>>>> Is that right?
>>>>
>>>>
>>>> From: Alex Harui<mailto:[hidden email]>
>>>> Sent: Wednesday, July 12, 2017 9:58 AM
>>>> To: [hidden email]<mailto:[hidden email]>
>>>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>>>> FileUploaderWithResponseData
>>>>
>>>> I think I still don't understand.
>>>>
>>>> It is ok for beads to require other beads.  If a ResponseData bead
>>>> requires a model with a slot for responseData and a controller that
>>>> knows
>>>> to record that data, that's how you are supposed to "re-compose"
>>>> components.  There doesn't have to be one model or controller per
>>>> component.  The strand is a gathering place for small pieces to work
>>>> together.
>>>>
>>>> I'm not sure what work CheckPermissions needs to do, but is totally
>>>> fine
>>>> to split its work amongst a set of beads.
>>>>
>>>> HTH,
>>>> -Alex
>>>>
>>>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>>>
>>>>> Ideally we wouldn't have to record data that's never read. This may
>>>>> be an
>>>>> extreme case, but some users will want to know the response on an
>>>>> upload,
>>>>> while some will just want to make sure the status is ok. I'd rather
>>>>> not
>>>>> anticipate too many use cases when writing the strand and the model
>>>>> because
>>>>> I might end up with code that's never used. If the bead was
>>>>> responsible
>>>>> for
>>>>> both recording the response and exposing it to the user, we wouldn't
>>>>> have
>>>>> to
>>>>> do that.
>>>>>
>>>>> Perhaps a better example is permissions. I already have an Upload
>>>>> bead.
>>>>> Now
>>>>> I want an alert to pop up if the user is not permitted to upload. I'd
>>>>> like
>>>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't
>>>>> see
>>>>> how to do that, instead I would probably have to replace 'UploadBead'
>>>>> with
>>>>> 'UploadButCheckPermissionsBead'. This takes us away from composition
>>>>> and
>>>>> forces inheritance.
>>>>>
>>>>> Maybe we don't need to modify class definitions. I think it's enough
>>>>> to
>>>>> modify the bead instance. In JS we could simply replace the function,
>>>>> and
>>>>> in
>>>>> flash we could maybe replace the whole original bead with a
>>>>> flash.utils.Proxy. But this will make things a bit complicated to read
>>>>> and
>>>>> maintain.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>>
>>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-
>>>>> fl
>>>>> e
>>>>>
>>>>> x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-head
>>>>> s-
>>>>> d
>>>>>
>>>>> evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01
>>>>> %7
>>>>> C
>>>>>
>>>>> %7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%
>>>>> 7C
>>>>> 0
>>>>>
>>>>> %7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2Bla
>>>>> F6
>>>>> d
>>>>> v8w%3D&reserved=0
>>>>> Sent from the Apache Flex Development mailing list archive at
>>>>> Nabble.com.
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Harbs
Thinking about this some more:

Order can be important, but that’s something that should be enforced by the strand. Where to add beads might change from strand to strand, but there should be some clear “point” where that happens (before beadsAdded). There needs to be a way to say "add a bead with the rest of them” and “add a bead now”. MXML and AS behavior should be the same.

Here’s what I’m thinking:

1. Strands should have a registerBead() method which takes a bead instance and adds it to a list, but does not yet add it.

2. addBead() should work exactly as it does today, but should be reserved for lazy instantiation, or early instantiation.

3. Strands should have a protected addBeads() method which takes no arguments, but adds all beads which were registered using registerBead(). Subclasses could override this method if necessary, but I don’t imagine this being usually necessary. One case where this would be important is when the order of beads is significant. For this to work, getBeadByType() would have to be modified to optionally get registered beads instead of added beads. The responsibility of order would rest on the Strand.

4. When addBeads() adds all the registered beads, it would send a beadsAdded notification to beads which care.

5. addBeads() would probably only ever be called once, but if there’s a valid reason to do so, maybe it can be called more than once and beadsAdded notification would be sent out again.

6. If there are cases where it’s necessary, pre/post beadsAdded notification could possibly be sent as well.

7. For beads when lazy instantiation does not make sense (i.e. most of the time), registerBead should be called for all beads in the constructor of the strand.

8. Beads declared in MXML, they should be instantiated with registerBead() rather than addBead(). That would allow code in set strand() to assume the strand is already properly set up, because the strand would only call addBeads() when it makes sense.

This would be a common lifecycle of all beads regardless of type. It should be easier to grok and give predictable behavior.

The notification vs events question is a separate point to ponder.

Thoughts?

> On Jul 14, 2017, at 3:38 AM, Harbs <[hidden email]> wrote:
>
> 1. I think so, or at most, only slightly. We’d probably save some code by not adding lots of functions for events and the like. I feel like the event system in general is bloated more than it needs to be.
> 2. I think there’s probably some and some. There’s probably going to be some lazy beads, and that’s ok. The way I see it is that there are two kinds of beads. There’s required ones which are not lazy and then there’s possibly-required, lazy ones. Lazy ones by definition will not need to listen for every notification. As long as there’s structure for the required ones, it’s good.
> 3. I think it’s okay to require certain classes of beads to be loaded in a certain order (i.e. controllers and views), as long as it doesn’t lead to pitfall bugs, but there’s probably others where requiring the order makes things difficult.
>
> Totally agree about the compiler bit.
>
> I generally think better by doing rather than writing.
>
> What I might do when I have some spare time is to do some experiments on a branch and see what happens. I have no problem if my experiments turn out to be pointless. Either way, it should be educational. I think it would give a concrete point of reference.
>
> Harbs
>
>> On Jul 14, 2017, at 2:48 AM, Alex Harui <[hidden email]> wrote:
>>
>> These are good points.  I'm glad I sent my PAYG email earlier today.  I'm
>> not sure I understood points #3 (dependencies) and #5 (cross-referencing)
>> so apologies if my thoughts below didn't take them into account.
>>
>> I'd say that some of these ideas simply need to be tried and measured
>> against the PAYG metrics I proposed.  For example:
>> 1) Can we implement a second, lighterweight notification system without
>> increasing download size?  Besides mediators I think there is another
>> mechanism called AS3Signals.
>> 2) Can we have more consistency in when beads get instantiated or will
>> that cause too many beads to be instantiated "just-in-case"?  It may just
>> be that "just-in-time" or "lazy" instantiation of beads is going to make
>> it hard to know when a bead will be added to the strand, but I think
>> "just-in-time" instantiation is always going to provide best performance.
>> Too much consistency sometimes results in too much just-in-case code.
>> 3) Is it better to require certain beads to be placed on the strand before
>> other beads?  Does doing so make the code smaller or faster?  Will it be
>> more painful for developers to get the order right?  It might be best just
>> to find the best patterns for waiting for your partner beads.  One thing
>> to consider is that we have more control over when beads get added in
>> MXML, but we probably shouldn't have control over when beads get added in
>> AS.  I don't think the compiler can or should detect when the application
>> developer is going to add a bead and tell them not to do it.
>>
>> There are probably at least two different "lifecycles".  Any individual
>> bead's lifecycle should be pretty simple: Instantiation, Initial
>> Properties, Add To Strand, Listen for Events/Notifications/Property
>> Changes.  Depending on how we decide #3 above, some beads may have a "wait
>> for my partner bead" phase.
>> A UI Component has a lifecycle of: Instantiation, Initial Properties, Add
>> To Parent, Add Beads.  But model beads may be instantiated and added on
>> demand in Initial Properties.  In "Add Beads" the model is added first if
>> not already added, then the view, then everything else.  In theory, the
>> "beadsAdded" event can be used by beads to know when significant changes
>> to the set of beads has occurred and that can be used to finish setting up
>> if you are waiting for partner beads, but otherwise, I think you can count
>> on model being instantiated on-demand and finish up in your strand setter.
>>
>> The idea I liked the least was the notion that the Strand was some
>> intermediary and beads talk to the Strand, tell the Strand what their
>> interest are and things like that.  In my view the strand is just a bus
>> like you mentioned and isn't involved in any communications.  The beads
>> simply use the bus to find each other and find the most PAYG way of
>> communicating.  
>>
>> Have you found common/popular patterns?  I don't really know because I've
>> been spending most of my time in the compiler.  If you have, then yes,
>> please document them.
>>
>> My 2 cents,
>> -Alex
>>
>> On 7/13/17, 3:40 PM, "Harbs" <[hidden email]> wrote:
>>
>>> Now that Yishay and I have spent quite some time with beads, I have some
>>> thoughts on the architecture.
>>>
>>> Here’s some things I’ve noticed (somewhat randomly):
>>>
>>> 1. There’s no clear place to add beads to components in AS. It seems like
>>> the catch-all place to do so is in addedToParent(), but many components
>>> add beads at other places. Many of these are lazy initialization and the
>>> like. There’s probably good reasons for all of these, but it’s confusing.
>>> Here’s a list of places where addBead() is called in Basic:
>>> start
>>> initHandler
>>> finishSetup
>>> set states
>>> get/set model
>>> get/set view
>>> get measurementBead
>>> setCursor
>>> get accordionCollapseBead
>>> get layout
>>> set strand
>>> createViewport
>>> createLists
>>> displayBackgroundAndBorder
>>> setupForBorder
>>> handleMessageChange
>>> get presentationModel
>>> constructor
>>>
>>> Especially for someone who is new to this, it’s very confusing to know
>>> where the right place to add a bead is.
>>>
>>> 2. It’s not immediately obvious that Beads can also be Strands. There are
>>> quite a few cases where that’s true. The only ones I’ve noticed were View
>>> Beads.
>>>
>>> 3. It’s hard to follow which beads have which dependencies. There are
>>> event listeners added at seemingly random places and events dispatched
>>> seemingly randomly as well. It’s hard to follow the flow.
>>>
>>> 4. It’s hard to know when beads are added and in what order.
>>>
>>> 5. Even if you know what other beads and events your bead relies on, you
>>> need to cross-reference to know what exact events are being dispatched.
>>>
>>> 6. The use of events is probably overkill for the needs of stands and
>>> beads. Strands are effectively a command bus for the beads (there’s many
>>> terms for the same concept). Events have significant overhead and
>>> indirection. Really what we need is for beads to tell the Strand “hey, I
>>> need to know when x happens so I can react and/or change what’s
>>> happening” and when beads do things they need to say “hey here’s what I
>>> did/ want to do”.
>>>
>>> 7. Beads have no way of knowing when they can finish setting up. The only
>>> way to do so is attach event listeners which is a bit awkward.
>>>
>>> I really like the Notification architecture in PureMVC, and I think it’s
>>> perfect for Strands and Beads.
>>>
>>> Without going into all the nitty gritty details, the classes have some
>>> standard info that the “mediator” can use to find who’s interested in
>>> what. The classes which need to react to specific notifications (i.e.
>>> Mediators) list their interests and they are directly notified when
>>> something that interests them happened.
>>>
>>> There’s also a clear lifecycle where functions can be called at
>>> predetermined times. Notification is done by using a Notification object
>>> which has three properties: name, type and body. Subscription to events
>>> happens through their names, but Notifications of the same name can
>>> modify their behavior by their type. body is an Object and can contain
>>> any kind of payload.
>>>
>>> I’d like to see a couple of things with Strands and Beads.
>>>
>>> 1. We should publish popular patterns for Strand/Bead interaction. (I’m
>>> talking to myself as much as anyone else.)
>>>
>>> 2. I’d like to have a clearly documented lifecycle for beads. There are
>>> some standard bead types such as Model, Controller, View, Content View.
>>> When should each of these be created and how? At critical points in this
>>> cycle, things should happen automatically: The strand should pull from
>>> each bead which is added what interests it has.
>>>
>>> 3. At the point when all “necessary” beads are added, the beads should
>>> have some method automatically called so they can “finish” their setup if
>>> they rely on another bead.
>>>
>>> 4. All Strands should have a “notify” method that beads can call to let
>>> the strand know to let the appropriate beads know about an event. The
>>> beads should send a notification with the necessary payload if one is
>>> needed. Other beads can modify this payload and/or change the
>>> notification type if necessary. The publisher of the notification can
>>> examine the notification after it’s sent to know if it needs to do
>>> something different.
>>>
>>> Bonus points if there’s some kind of “post process” on notifications in
>>> case a bead needs to wait until after some other bead did their thing.
>>> This can take the form of a “registerPostProcess” call to the bead which
>>> is only every called once per registration.
>>>
>>> 5. I’m likely missing some points in the lifecycle…
>>>
>>> This is something that I’d work on if others think this makes any kind of
>>> sense. While a lot of this is not very different from how events are
>>> working today, it feels to me like it would help give the strand/bead
>>> relationships a lot more structure.
>>>
>>> Thoughts?
>>> Harbs
>>>
>>>>
>>>> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]>
>>>> wrote:
>>>>
>>>> Yes, that's how I think of it.  You are right that getting one bead in a
>>>> multi bead set to listen to other beads is tricky.  UIBase defines a
>>>> particular order of model first, then view, then controller.  But
>>>> otherwise, you either have to dictate your own order or find another
>>>> event
>>>> to listen to that will give a bead another chance to search the strand
>>>> for
>>>> other beads to listen to.  There is a "beadsAdded" event that can be
>>>> used.
>>>>
>>>> Maybe as more folks implement multi-bead sets we'll see patterns emerge
>>>> and make it is simpler and faster.
>>>>
>>>> My 2 cents,
>>>> -Alex
>>>>
>>>> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>>>>
>>>>> Generally speaking it feels like sometimes I need to insure the order
>>>>> of
>>>>> invocation. Since beads communicate with one another through events
>>>>> it’s
>>>>> difficult to achieve. Regarding the upload response data I understand
>>>>> your suggestion as follows (edges contain event names):
>>>>>
>>>>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>>>>> request)>---complete---<ModelWithResponse (after controller wrote to
>>>>> model>---modelChanged--<UserClassListening>
>>>>>
>>>>> And for the case where the user isn’t interested in the response, just
>>>>> in
>>>>> the status:
>>>>>
>>>>>
>>>>> <Strand>---uploadRequested--<controllerForWithoutResponse>---complete---
>>>>> <M
>>>>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>>>>
>>>>> Is that right?
>>>>>
>>>>>
>>>>> From: Alex Harui<mailto:[hidden email]>
>>>>> Sent: Wednesday, July 12, 2017 9:58 AM
>>>>> To: [hidden email]<mailto:[hidden email]>
>>>>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>>>>> FileUploaderWithResponseData
>>>>>
>>>>> I think I still don't understand.
>>>>>
>>>>> It is ok for beads to require other beads.  If a ResponseData bead
>>>>> requires a model with a slot for responseData and a controller that
>>>>> knows
>>>>> to record that data, that's how you are supposed to "re-compose"
>>>>> components.  There doesn't have to be one model or controller per
>>>>> component.  The strand is a gathering place for small pieces to work
>>>>> together.
>>>>>
>>>>> I'm not sure what work CheckPermissions needs to do, but is totally
>>>>> fine
>>>>> to split its work amongst a set of beads.
>>>>>
>>>>> HTH,
>>>>> -Alex
>>>>>
>>>>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>>>>
>>>>>> Ideally we wouldn't have to record data that's never read. This may
>>>>>> be an
>>>>>> extreme case, but some users will want to know the response on an
>>>>>> upload,
>>>>>> while some will just want to make sure the status is ok. I'd rather
>>>>>> not
>>>>>> anticipate too many use cases when writing the strand and the model
>>>>>> because
>>>>>> I might end up with code that's never used. If the bead was
>>>>>> responsible
>>>>>> for
>>>>>> both recording the response and exposing it to the user, we wouldn't
>>>>>> have
>>>>>> to
>>>>>> do that.
>>>>>>
>>>>>> Perhaps a better example is permissions. I already have an Upload
>>>>>> bead.
>>>>>> Now
>>>>>> I want an alert to pop up if the user is not permitted to upload. I'd
>>>>>> like
>>>>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I don't
>>>>>> see
>>>>>> how to do that, instead I would probably have to replace 'UploadBead'
>>>>>> with
>>>>>> 'UploadButCheckPermissionsBead'. This takes us away from composition
>>>>>> and
>>>>>> forces inheritance.
>>>>>>
>>>>>> Maybe we don't need to modify class definitions. I think it's enough
>>>>>> to
>>>>>> modify the bead instance. In JS we could simply replace the function,
>>>>>> and
>>>>>> in
>>>>>> flash we could maybe replace the whole original bead with a
>>>>>> flash.utils.Proxy. But this will make things a bit complicated to read
>>>>>> and
>>>>>> maintain.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>>
>>>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-
>>>>>> fl
>>>>>> e
>>>>>>
>>>>>> x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-head
>>>>>> s-
>>>>>> d
>>>>>>
>>>>>> evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7C01
>>>>>> %7
>>>>>> C
>>>>>>
>>>>>> %7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178decee1%
>>>>>> 7C
>>>>>> 0
>>>>>>
>>>>>> %7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2Bla
>>>>>> F6
>>>>>> d
>>>>>> v8w%3D&reserved=0
>>>>>> Sent from the Apache Flex Development mailing list archive at
>>>>>> Nabble.com.
>>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Alex Harui-2
For sure, it probably isn't efficient to try to think this out on the
mailing list.  So, if this is important to you, find the time to code it
up and see how it turns out.

My first impression of an 8-step lifecycle is not positive.  Sounds like a
lot of steps.  The lifecycle I described upthread, which seems to be fine
for the vast majority of beads that don't talk with other beads, was only
4 steps.  Maybe there can be a different lifecycle for beads that need to
find each other.

Also, I don't think there is any way to make MXML and AS behavior the same
without placing a lot of constraints on how AS is written, which I don't
think is a good idea.

I still expect Lazy or Just-in-time Instantiation to be the most
performant and lazy instantiation will cause beads to be added at any
time.  Creating all beads in the Constructor is likely to miss important
scenarios like using CSS to determine which bead to use.
Or allow language/locale specific beads that are determined at runtime by
user selection from a dropdown.  Or data parsing beads that are determined
based on the kind of data returned from a network request.

Maybe it will help if you can describe some scenarios where beads need to
find each other and those beads are not the model or view beads since we
always make them seem like they are put on first because they are created
on-demand.

Maybe the answer is as simple as: a bead that requires another bead simply
throws an error if it can't find the bead on the strand.  That will clue
in the developer to add beads in the right order.  We've recently learned
how to write such error messages in ways that they don't end up in
production code.

And/or, there might be scenarios where the prerequisite bead is specified
in the ValuesManager, and some new utility function called
getBeadByTypeAndInstantiateItIfYouCan'tFindIt will create it and added to
the strand and return a pointer to it.

And in some cases, a bead can look for its partner and if it isn't there,
just do nothing.  Then when the partner comes in it finds the first bead
and says, "hey I'm here".

IMO, beads are just another scenario of asynchronous programming.  If you
make two network requests without waiting for the first one to return, you
can't guarantee the order in which they return.  I think I saw in regular
Flex someone try to load two modules and they might return in different
order and if they had to find each other, they had to create a similar
protocol.  Maybe there can be a base class for beads that need to find
each other that has some built-in code that manages this protocol.

Just thinking out loud,
-Alex

On 7/14/17, 12:46 AM, "Harbs" <[hidden email]> wrote:

>Thinking about this some more:
>
>Order can be important, but that’s something that should be enforced by
>the strand. Where to add beads might change from strand to strand, but
>there should be some clear “point” where that happens (before
>beadsAdded). There needs to be a way to say "add a bead with the rest of
>them” and “add a bead now”. MXML and AS behavior should be the same.
>
>Here’s what I’m thinking:
>
>1. Strands should have a registerBead() method which takes a bead
>instance and adds it to a list, but does not yet add it.
>
>2. addBead() should work exactly as it does today, but should be reserved
>for lazy instantiation, or early instantiation.
>
>3. Strands should have a protected addBeads() method which takes no
>arguments, but adds all beads which were registered using registerBead().
>Subclasses could override this method if necessary, but I don’t imagine
>this being usually necessary. One case where this would be important is
>when the order of beads is significant. For this to work, getBeadByType()
>would have to be modified to optionally get registered beads instead of
>added beads. The responsibility of order would rest on the Strand.
>
>4. When addBeads() adds all the registered beads, it would send a
>beadsAdded notification to beads which care.
>
>5. addBeads() would probably only ever be called once, but if there’s a
>valid reason to do so, maybe it can be called more than once and
>beadsAdded notification would be sent out again.
>
>6. If there are cases where it’s necessary, pre/post beadsAdded
>notification could possibly be sent as well.
>
>7. For beads when lazy instantiation does not make sense (i.e. most of
>the time), registerBead should be called for all beads in the constructor
>of the strand.
>
>8. Beads declared in MXML, they should be instantiated with
>registerBead() rather than addBead(). That would allow code in set
>strand() to assume the strand is already properly set up, because the
>strand would only call addBeads() when it makes sense.
>
>This would be a common lifecycle of all beads regardless of type. It
>should be easier to grok and give predictable behavior.
>
>The notification vs events question is a separate point to ponder.
>
>Thoughts?
>
>> On Jul 14, 2017, at 3:38 AM, Harbs <[hidden email]> wrote:
>>
>> 1. I think so, or at most, only slightly. We’d probably save some code
>>by not adding lots of functions for events and the like. I feel like the
>>event system in general is bloated more than it needs to be.
>> 2. I think there’s probably some and some. There’s probably going to be
>>some lazy beads, and that’s ok. The way I see it is that there are two
>>kinds of beads. There’s required ones which are not lazy and then
>>there’s possibly-required, lazy ones. Lazy ones by definition will not
>>need to listen for every notification. As long as there’s structure for
>>the required ones, it’s good.
>> 3. I think it’s okay to require certain classes of beads to be loaded
>>in a certain order (i.e. controllers and views), as long as it doesn’t
>>lead to pitfall bugs, but there’s probably others where requiring the
>>order makes things difficult.
>>
>> Totally agree about the compiler bit.
>>
>> I generally think better by doing rather than writing.
>>
>> What I might do when I have some spare time is to do some experiments
>>on a branch and see what happens. I have no problem if my experiments
>>turn out to be pointless. Either way, it should be educational. I think
>>it would give a concrete point of reference.
>>
>> Harbs
>>
>>> On Jul 14, 2017, at 2:48 AM, Alex Harui <[hidden email]>
>>>wrote:
>>>
>>> These are good points.  I'm glad I sent my PAYG email earlier today.
>>>I'm
>>> not sure I understood points #3 (dependencies) and #5
>>>(cross-referencing)
>>> so apologies if my thoughts below didn't take them into account.
>>>
>>> I'd say that some of these ideas simply need to be tried and measured
>>> against the PAYG metrics I proposed.  For example:
>>> 1) Can we implement a second, lighterweight notification system without
>>> increasing download size?  Besides mediators I think there is another
>>> mechanism called AS3Signals.
>>> 2) Can we have more consistency in when beads get instantiated or will
>>> that cause too many beads to be instantiated "just-in-case"?  It may
>>>just
>>> be that "just-in-time" or "lazy" instantiation of beads is going to
>>>make
>>> it hard to know when a bead will be added to the strand, but I think
>>> "just-in-time" instantiation is always going to provide best
>>>performance.
>>> Too much consistency sometimes results in too much just-in-case code.
>>> 3) Is it better to require certain beads to be placed on the strand
>>>before
>>> other beads?  Does doing so make the code smaller or faster?  Will it
>>>be
>>> more painful for developers to get the order right?  It might be best
>>>just
>>> to find the best patterns for waiting for your partner beads.  One
>>>thing
>>> to consider is that we have more control over when beads get added in
>>> MXML, but we probably shouldn't have control over when beads get added
>>>in
>>> AS.  I don't think the compiler can or should detect when the
>>>application
>>> developer is going to add a bead and tell them not to do it.
>>>
>>> There are probably at least two different "lifecycles".  Any individual
>>> bead's lifecycle should be pretty simple: Instantiation, Initial
>>> Properties, Add To Strand, Listen for Events/Notifications/Property
>>> Changes.  Depending on how we decide #3 above, some beads may have a
>>>"wait
>>> for my partner bead" phase.
>>> A UI Component has a lifecycle of: Instantiation, Initial Properties,
>>>Add
>>> To Parent, Add Beads.  But model beads may be instantiated and added on
>>> demand in Initial Properties.  In "Add Beads" the model is added first
>>>if
>>> not already added, then the view, then everything else.  In theory, the
>>> "beadsAdded" event can be used by beads to know when significant
>>>changes
>>> to the set of beads has occurred and that can be used to finish
>>>setting up
>>> if you are waiting for partner beads, but otherwise, I think you can
>>>count
>>> on model being instantiated on-demand and finish up in your strand
>>>setter.
>>>
>>> The idea I liked the least was the notion that the Strand was some
>>> intermediary and beads talk to the Strand, tell the Strand what their
>>> interest are and things like that.  In my view the strand is just a bus
>>> like you mentioned and isn't involved in any communications.  The beads
>>> simply use the bus to find each other and find the most PAYG way of
>>> communicating.
>>>
>>> Have you found common/popular patterns?  I don't really know because
>>>I've
>>> been spending most of my time in the compiler.  If you have, then yes,
>>> please document them.
>>>
>>> My 2 cents,
>>> -Alex
>>>
>>> On 7/13/17, 3:40 PM, "Harbs" <[hidden email]> wrote:
>>>
>>>> Now that Yishay and I have spent quite some time with beads, I have
>>>>some
>>>> thoughts on the architecture.
>>>>
>>>> Here’s some things I’ve noticed (somewhat randomly):
>>>>
>>>> 1. There’s no clear place to add beads to components in AS. It seems
>>>>like
>>>> the catch-all place to do so is in addedToParent(), but many
>>>>components
>>>> add beads at other places. Many of these are lazy initialization and
>>>>the
>>>> like. There’s probably good reasons for all of these, but it’s
>>>>confusing.
>>>> Here’s a list of places where addBead() is called in Basic:
>>>> start
>>>> initHandler
>>>> finishSetup
>>>> set states
>>>> get/set model
>>>> get/set view
>>>> get measurementBead
>>>> setCursor
>>>> get accordionCollapseBead
>>>> get layout
>>>> set strand
>>>> createViewport
>>>> createLists
>>>> displayBackgroundAndBorder
>>>> setupForBorder
>>>> handleMessageChange
>>>> get presentationModel
>>>> constructor
>>>>
>>>> Especially for someone who is new to this, it’s very confusing to know
>>>> where the right place to add a bead is.
>>>>
>>>> 2. It’s not immediately obvious that Beads can also be Strands. There
>>>>are
>>>> quite a few cases where that’s true. The only ones I’ve noticed were
>>>>View
>>>> Beads.
>>>>
>>>> 3. It’s hard to follow which beads have which dependencies. There are
>>>> event listeners added at seemingly random places and events dispatched
>>>> seemingly randomly as well. It’s hard to follow the flow.
>>>>
>>>> 4. It’s hard to know when beads are added and in what order.
>>>>
>>>> 5. Even if you know what other beads and events your bead relies on,
>>>>you
>>>> need to cross-reference to know what exact events are being
>>>>dispatched.
>>>>
>>>> 6. The use of events is probably overkill for the needs of stands and
>>>> beads. Strands are effectively a command bus for the beads (there’s
>>>>many
>>>> terms for the same concept). Events have significant overhead and
>>>> indirection. Really what we need is for beads to tell the Strand
>>>>“hey, I
>>>> need to know when x happens so I can react and/or change what’s
>>>> happening” and when beads do things they need to say “hey here’s what
>>>>I
>>>> did/ want to do”.
>>>>
>>>> 7. Beads have no way of knowing when they can finish setting up. The
>>>>only
>>>> way to do so is attach event listeners which is a bit awkward.
>>>>
>>>> I really like the Notification architecture in PureMVC, and I think
>>>>it’s
>>>> perfect for Strands and Beads.
>>>>
>>>> Without going into all the nitty gritty details, the classes have some
>>>> standard info that the “mediator” can use to find who’s interested in
>>>> what. The classes which need to react to specific notifications (i.e.
>>>> Mediators) list their interests and they are directly notified when
>>>> something that interests them happened.
>>>>
>>>> There’s also a clear lifecycle where functions can be called at
>>>> predetermined times. Notification is done by using a Notification
>>>>object
>>>> which has three properties: name, type and body. Subscription to
>>>>events
>>>> happens through their names, but Notifications of the same name can
>>>> modify their behavior by their type. body is an Object and can contain
>>>> any kind of payload.
>>>>
>>>> I’d like to see a couple of things with Strands and Beads.
>>>>
>>>> 1. We should publish popular patterns for Strand/Bead interaction.
>>>>(I’m
>>>> talking to myself as much as anyone else.)
>>>>
>>>> 2. I’d like to have a clearly documented lifecycle for beads. There
>>>>are
>>>> some standard bead types such as Model, Controller, View, Content
>>>>View.
>>>> When should each of these be created and how? At critical points in
>>>>this
>>>> cycle, things should happen automatically: The strand should pull from
>>>> each bead which is added what interests it has.
>>>>
>>>> 3. At the point when all “necessary” beads are added, the beads should
>>>> have some method automatically called so they can “finish” their
>>>>setup if
>>>> they rely on another bead.
>>>>
>>>> 4. All Strands should have a “notify” method that beads can call to
>>>>let
>>>> the strand know to let the appropriate beads know about an event. The
>>>> beads should send a notification with the necessary payload if one is
>>>> needed. Other beads can modify this payload and/or change the
>>>> notification type if necessary. The publisher of the notification can
>>>> examine the notification after it’s sent to know if it needs to do
>>>> something different.
>>>>
>>>> Bonus points if there’s some kind of “post process” on notifications
>>>>in
>>>> case a bead needs to wait until after some other bead did their thing.
>>>> This can take the form of a “registerPostProcess” call to the bead
>>>>which
>>>> is only every called once per registration.
>>>>
>>>> 5. I’m likely missing some points in the lifecycle…
>>>>
>>>> This is something that I’d work on if others think this makes any
>>>>kind of
>>>> sense. While a lot of this is not very different from how events are
>>>> working today, it feels to me like it would help give the strand/bead
>>>> relationships a lot more structure.
>>>>
>>>> Thoughts?
>>>> Harbs
>>>>
>>>>>
>>>>> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]>
>>>>> wrote:
>>>>>
>>>>> Yes, that's how I think of it.  You are right that getting one bead
>>>>>in a
>>>>> multi bead set to listen to other beads is tricky.  UIBase defines a
>>>>> particular order of model first, then view, then controller.  But
>>>>> otherwise, you either have to dictate your own order or find another
>>>>> event
>>>>> to listen to that will give a bead another chance to search the
>>>>>strand
>>>>> for
>>>>> other beads to listen to.  There is a "beadsAdded" event that can be
>>>>> used.
>>>>>
>>>>> Maybe as more folks implement multi-bead sets we'll see patterns
>>>>>emerge
>>>>> and make it is simpler and faster.
>>>>>
>>>>> My 2 cents,
>>>>> -Alex
>>>>>
>>>>> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>>>>>
>>>>>> Generally speaking it feels like sometimes I need to insure the
>>>>>>order
>>>>>> of
>>>>>> invocation. Since beads communicate with one another through events
>>>>>> it’s
>>>>>> difficult to achieve. Regarding the upload response data I
>>>>>>understand
>>>>>> your suggestion as follows (edges contain event names):
>>>>>>
>>>>>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>>>>>> request)>---complete---<ModelWithResponse (after controller wrote to
>>>>>> model>---modelChanged--<UserClassListening>
>>>>>>
>>>>>> And for the case where the user isn’t interested in the response,
>>>>>>just
>>>>>> in
>>>>>> the status:
>>>>>>
>>>>>>
>>>>>>
>>>>>><Strand>---uploadRequested--<controllerForWithoutResponse>---complete
>>>>>>---
>>>>>> <M
>>>>>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>>>>>
>>>>>> Is that right?
>>>>>>
>>>>>>
>>>>>> From: Alex Harui<mailto:[hidden email]>
>>>>>> Sent: Wednesday, July 12, 2017 9:58 AM
>>>>>> To: [hidden email]<mailto:[hidden email]>
>>>>>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>>>>>> FileUploaderWithResponseData
>>>>>>
>>>>>> I think I still don't understand.
>>>>>>
>>>>>> It is ok for beads to require other beads.  If a ResponseData bead
>>>>>> requires a model with a slot for responseData and a controller that
>>>>>> knows
>>>>>> to record that data, that's how you are supposed to "re-compose"
>>>>>> components.  There doesn't have to be one model or controller per
>>>>>> component.  The strand is a gathering place for small pieces to work
>>>>>> together.
>>>>>>
>>>>>> I'm not sure what work CheckPermissions needs to do, but is totally
>>>>>> fine
>>>>>> to split its work amongst a set of beads.
>>>>>>
>>>>>> HTH,
>>>>>> -Alex
>>>>>>
>>>>>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>>>>>
>>>>>>> Ideally we wouldn't have to record data that's never read. This may
>>>>>>> be an
>>>>>>> extreme case, but some users will want to know the response on an
>>>>>>> upload,
>>>>>>> while some will just want to make sure the status is ok. I'd rather
>>>>>>> not
>>>>>>> anticipate too many use cases when writing the strand and the model
>>>>>>> because
>>>>>>> I might end up with code that's never used. If the bead was
>>>>>>> responsible
>>>>>>> for
>>>>>>> both recording the response and exposing it to the user, we
>>>>>>>wouldn't
>>>>>>> have
>>>>>>> to
>>>>>>> do that.
>>>>>>>
>>>>>>> Perhaps a better example is permissions. I already have an Upload
>>>>>>> bead.
>>>>>>> Now
>>>>>>> I want an alert to pop up if the user is not permitted to upload.
>>>>>>>I'd
>>>>>>> like
>>>>>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I
>>>>>>>don't
>>>>>>> see
>>>>>>> how to do that, instead I would probably have to replace
>>>>>>>'UploadBead'
>>>>>>> with
>>>>>>> 'UploadButCheckPermissionsBead'. This takes us away from
>>>>>>>composition
>>>>>>> and
>>>>>>> forces inheritance.
>>>>>>>
>>>>>>> Maybe we don't need to modify class definitions. I think it's
>>>>>>>enough
>>>>>>> to
>>>>>>> modify the bead instance. In JS we could simply replace the
>>>>>>>function,
>>>>>>> and
>>>>>>> in
>>>>>>> flash we could maybe replace the whole original bead with a
>>>>>>> flash.utils.Proxy. But this will make things a bit complicated to
>>>>>>>read
>>>>>>> and
>>>>>>> maintain.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>>
>>>>>>>
>>>>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapac
>>>>>>>he-
>>>>>>> fl
>>>>>>> e
>>>>>>>
>>>>>>>
>>>>>>>x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-h
>>>>>>>ead
>>>>>>> s-
>>>>>>> d
>>>>>>>
>>>>>>>
>>>>>>>evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7
>>>>>>>C01
>>>>>>> %7
>>>>>>> C
>>>>>>>
>>>>>>>
>>>>>>>%7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178dece
>>>>>>>e1%
>>>>>>> 7C
>>>>>>> 0
>>>>>>>
>>>>>>>
>>>>>>>%7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2
>>>>>>>Bla
>>>>>>> F6
>>>>>>> d
>>>>>>> v8w%3D&reserved=0
>>>>>>> Sent from the Apache Flex Development mailing list archive at
>>>>>>> Nabble.com.
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData

Justin Mclean
Administrator
In reply to this post by yishayw
Hi,

You may want to look into using the decorator pattern [1]. It's a nice way of adding one or more pieces of functionality to a class without using inheritance. Here’s an AS example i did ages ago [2] for a state machine that you can add logging or event dispatching or both to.

Thanks,
Justin

1. https://en.wikipedia.org/wiki/Decorator_pattern
2. https://github.com/justinmclean/ActionScript-State-Machine/tree/master/src/com/classsoftware/statemachine
Reply | Threaded
Open this post in threaded view
|

Re: Bead Lifecycle (was Re: git commit: [flex-asjs] [refs/heads/develop] - Add FileUploaderWithResponseData)

Harbs
In reply to this post by Alex Harui-2
It’s not an 8 step lifecycle. The only extra step is the registerBead step.

The rest is dealing with the peculiarities of different scenarios.

FWIW, none of this will be enforced, so there’s nothing to stop anyone from using beads exactly as they are used today.

Once I finish my experiment, let’s discuss some more…

> On Jul 14, 2017, at 7:13 PM, Alex Harui <[hidden email]> wrote:
>
> For sure, it probably isn't efficient to try to think this out on the
> mailing list.  So, if this is important to you, find the time to code it
> up and see how it turns out.
>
> My first impression of an 8-step lifecycle is not positive.  Sounds like a
> lot of steps.  The lifecycle I described upthread, which seems to be fine
> for the vast majority of beads that don't talk with other beads, was only
> 4 steps.  Maybe there can be a different lifecycle for beads that need to
> find each other.
>
> Also, I don't think there is any way to make MXML and AS behavior the same
> without placing a lot of constraints on how AS is written, which I don't
> think is a good idea.
>
> I still expect Lazy or Just-in-time Instantiation to be the most
> performant and lazy instantiation will cause beads to be added at any
> time.  Creating all beads in the Constructor is likely to miss important
> scenarios like using CSS to determine which bead to use.
> Or allow language/locale specific beads that are determined at runtime by
> user selection from a dropdown.  Or data parsing beads that are determined
> based on the kind of data returned from a network request.
>
> Maybe it will help if you can describe some scenarios where beads need to
> find each other and those beads are not the model or view beads since we
> always make them seem like they are put on first because they are created
> on-demand.
>
> Maybe the answer is as simple as: a bead that requires another bead simply
> throws an error if it can't find the bead on the strand.  That will clue
> in the developer to add beads in the right order.  We've recently learned
> how to write such error messages in ways that they don't end up in
> production code.
>
> And/or, there might be scenarios where the prerequisite bead is specified
> in the ValuesManager, and some new utility function called
> getBeadByTypeAndInstantiateItIfYouCan'tFindIt will create it and added to
> the strand and return a pointer to it.
>
> And in some cases, a bead can look for its partner and if it isn't there,
> just do nothing.  Then when the partner comes in it finds the first bead
> and says, "hey I'm here".
>
> IMO, beads are just another scenario of asynchronous programming.  If you
> make two network requests without waiting for the first one to return, you
> can't guarantee the order in which they return.  I think I saw in regular
> Flex someone try to load two modules and they might return in different
> order and if they had to find each other, they had to create a similar
> protocol.  Maybe there can be a base class for beads that need to find
> each other that has some built-in code that manages this protocol.
>
> Just thinking out loud,
> -Alex
>
> On 7/14/17, 12:46 AM, "Harbs" <[hidden email]> wrote:
>
>> Thinking about this some more:
>>
>> Order can be important, but that’s something that should be enforced by
>> the strand. Where to add beads might change from strand to strand, but
>> there should be some clear “point” where that happens (before
>> beadsAdded). There needs to be a way to say "add a bead with the rest of
>> them” and “add a bead now”. MXML and AS behavior should be the same.
>>
>> Here’s what I’m thinking:
>>
>> 1. Strands should have a registerBead() method which takes a bead
>> instance and adds it to a list, but does not yet add it.
>>
>> 2. addBead() should work exactly as it does today, but should be reserved
>> for lazy instantiation, or early instantiation.
>>
>> 3. Strands should have a protected addBeads() method which takes no
>> arguments, but adds all beads which were registered using registerBead().
>> Subclasses could override this method if necessary, but I don’t imagine
>> this being usually necessary. One case where this would be important is
>> when the order of beads is significant. For this to work, getBeadByType()
>> would have to be modified to optionally get registered beads instead of
>> added beads. The responsibility of order would rest on the Strand.
>>
>> 4. When addBeads() adds all the registered beads, it would send a
>> beadsAdded notification to beads which care.
>>
>> 5. addBeads() would probably only ever be called once, but if there’s a
>> valid reason to do so, maybe it can be called more than once and
>> beadsAdded notification would be sent out again.
>>
>> 6. If there are cases where it’s necessary, pre/post beadsAdded
>> notification could possibly be sent as well.
>>
>> 7. For beads when lazy instantiation does not make sense (i.e. most of
>> the time), registerBead should be called for all beads in the constructor
>> of the strand.
>>
>> 8. Beads declared in MXML, they should be instantiated with
>> registerBead() rather than addBead(). That would allow code in set
>> strand() to assume the strand is already properly set up, because the
>> strand would only call addBeads() when it makes sense.
>>
>> This would be a common lifecycle of all beads regardless of type. It
>> should be easier to grok and give predictable behavior.
>>
>> The notification vs events question is a separate point to ponder.
>>
>> Thoughts?
>>
>>> On Jul 14, 2017, at 3:38 AM, Harbs <[hidden email]> wrote:
>>>
>>> 1. I think so, or at most, only slightly. We’d probably save some code
>>> by not adding lots of functions for events and the like. I feel like the
>>> event system in general is bloated more than it needs to be.
>>> 2. I think there’s probably some and some. There’s probably going to be
>>> some lazy beads, and that’s ok. The way I see it is that there are two
>>> kinds of beads. There’s required ones which are not lazy and then
>>> there’s possibly-required, lazy ones. Lazy ones by definition will not
>>> need to listen for every notification. As long as there’s structure for
>>> the required ones, it’s good.
>>> 3. I think it’s okay to require certain classes of beads to be loaded
>>> in a certain order (i.e. controllers and views), as long as it doesn’t
>>> lead to pitfall bugs, but there’s probably others where requiring the
>>> order makes things difficult.
>>>
>>> Totally agree about the compiler bit.
>>>
>>> I generally think better by doing rather than writing.
>>>
>>> What I might do when I have some spare time is to do some experiments
>>> on a branch and see what happens. I have no problem if my experiments
>>> turn out to be pointless. Either way, it should be educational. I think
>>> it would give a concrete point of reference.
>>>
>>> Harbs
>>>
>>>> On Jul 14, 2017, at 2:48 AM, Alex Harui <[hidden email]>
>>>> wrote:
>>>>
>>>> These are good points.  I'm glad I sent my PAYG email earlier today.
>>>> I'm
>>>> not sure I understood points #3 (dependencies) and #5
>>>> (cross-referencing)
>>>> so apologies if my thoughts below didn't take them into account.
>>>>
>>>> I'd say that some of these ideas simply need to be tried and measured
>>>> against the PAYG metrics I proposed.  For example:
>>>> 1) Can we implement a second, lighterweight notification system without
>>>> increasing download size?  Besides mediators I think there is another
>>>> mechanism called AS3Signals.
>>>> 2) Can we have more consistency in when beads get instantiated or will
>>>> that cause too many beads to be instantiated "just-in-case"?  It may
>>>> just
>>>> be that "just-in-time" or "lazy" instantiation of beads is going to
>>>> make
>>>> it hard to know when a bead will be added to the strand, but I think
>>>> "just-in-time" instantiation is always going to provide best
>>>> performance.
>>>> Too much consistency sometimes results in too much just-in-case code.
>>>> 3) Is it better to require certain beads to be placed on the strand
>>>> before
>>>> other beads?  Does doing so make the code smaller or faster?  Will it
>>>> be
>>>> more painful for developers to get the order right?  It might be best
>>>> just
>>>> to find the best patterns for waiting for your partner beads.  One
>>>> thing
>>>> to consider is that we have more control over when beads get added in
>>>> MXML, but we probably shouldn't have control over when beads get added
>>>> in
>>>> AS.  I don't think the compiler can or should detect when the
>>>> application
>>>> developer is going to add a bead and tell them not to do it.
>>>>
>>>> There are probably at least two different "lifecycles".  Any individual
>>>> bead's lifecycle should be pretty simple: Instantiation, Initial
>>>> Properties, Add To Strand, Listen for Events/Notifications/Property
>>>> Changes.  Depending on how we decide #3 above, some beads may have a
>>>> "wait
>>>> for my partner bead" phase.
>>>> A UI Component has a lifecycle of: Instantiation, Initial Properties,
>>>> Add
>>>> To Parent, Add Beads.  But model beads may be instantiated and added on
>>>> demand in Initial Properties.  In "Add Beads" the model is added first
>>>> if
>>>> not already added, then the view, then everything else.  In theory, the
>>>> "beadsAdded" event can be used by beads to know when significant
>>>> changes
>>>> to the set of beads has occurred and that can be used to finish
>>>> setting up
>>>> if you are waiting for partner beads, but otherwise, I think you can
>>>> count
>>>> on model being instantiated on-demand and finish up in your strand
>>>> setter.
>>>>
>>>> The idea I liked the least was the notion that the Strand was some
>>>> intermediary and beads talk to the Strand, tell the Strand what their
>>>> interest are and things like that.  In my view the strand is just a bus
>>>> like you mentioned and isn't involved in any communications.  The beads
>>>> simply use the bus to find each other and find the most PAYG way of
>>>> communicating.
>>>>
>>>> Have you found common/popular patterns?  I don't really know because
>>>> I've
>>>> been spending most of my time in the compiler.  If you have, then yes,
>>>> please document them.
>>>>
>>>> My 2 cents,
>>>> -Alex
>>>>
>>>> On 7/13/17, 3:40 PM, "Harbs" <[hidden email]> wrote:
>>>>
>>>>> Now that Yishay and I have spent quite some time with beads, I have
>>>>> some
>>>>> thoughts on the architecture.
>>>>>
>>>>> Here’s some things I’ve noticed (somewhat randomly):
>>>>>
>>>>> 1. There’s no clear place to add beads to components in AS. It seems
>>>>> like
>>>>> the catch-all place to do so is in addedToParent(), but many
>>>>> components
>>>>> add beads at other places. Many of these are lazy initialization and
>>>>> the
>>>>> like. There’s probably good reasons for all of these, but it’s
>>>>> confusing.
>>>>> Here’s a list of places where addBead() is called in Basic:
>>>>> start
>>>>> initHandler
>>>>> finishSetup
>>>>> set states
>>>>> get/set model
>>>>> get/set view
>>>>> get measurementBead
>>>>> setCursor
>>>>> get accordionCollapseBead
>>>>> get layout
>>>>> set strand
>>>>> createViewport
>>>>> createLists
>>>>> displayBackgroundAndBorder
>>>>> setupForBorder
>>>>> handleMessageChange
>>>>> get presentationModel
>>>>> constructor
>>>>>
>>>>> Especially for someone who is new to this, it’s very confusing to know
>>>>> where the right place to add a bead is.
>>>>>
>>>>> 2. It’s not immediately obvious that Beads can also be Strands. There
>>>>> are
>>>>> quite a few cases where that’s true. The only ones I’ve noticed were
>>>>> View
>>>>> Beads.
>>>>>
>>>>> 3. It’s hard to follow which beads have which dependencies. There are
>>>>> event listeners added at seemingly random places and events dispatched
>>>>> seemingly randomly as well. It’s hard to follow the flow.
>>>>>
>>>>> 4. It’s hard to know when beads are added and in what order.
>>>>>
>>>>> 5. Even if you know what other beads and events your bead relies on,
>>>>> you
>>>>> need to cross-reference to know what exact events are being
>>>>> dispatched.
>>>>>
>>>>> 6. The use of events is probably overkill for the needs of stands and
>>>>> beads. Strands are effectively a command bus for the beads (there’s
>>>>> many
>>>>> terms for the same concept). Events have significant overhead and
>>>>> indirection. Really what we need is for beads to tell the Strand
>>>>> “hey, I
>>>>> need to know when x happens so I can react and/or change what’s
>>>>> happening” and when beads do things they need to say “hey here’s what
>>>>> I
>>>>> did/ want to do”.
>>>>>
>>>>> 7. Beads have no way of knowing when they can finish setting up. The
>>>>> only
>>>>> way to do so is attach event listeners which is a bit awkward.
>>>>>
>>>>> I really like the Notification architecture in PureMVC, and I think
>>>>> it’s
>>>>> perfect for Strands and Beads.
>>>>>
>>>>> Without going into all the nitty gritty details, the classes have some
>>>>> standard info that the “mediator” can use to find who’s interested in
>>>>> what. The classes which need to react to specific notifications (i.e.
>>>>> Mediators) list their interests and they are directly notified when
>>>>> something that interests them happened.
>>>>>
>>>>> There’s also a clear lifecycle where functions can be called at
>>>>> predetermined times. Notification is done by using a Notification
>>>>> object
>>>>> which has three properties: name, type and body. Subscription to
>>>>> events
>>>>> happens through their names, but Notifications of the same name can
>>>>> modify their behavior by their type. body is an Object and can contain
>>>>> any kind of payload.
>>>>>
>>>>> I’d like to see a couple of things with Strands and Beads.
>>>>>
>>>>> 1. We should publish popular patterns for Strand/Bead interaction.
>>>>> (I’m
>>>>> talking to myself as much as anyone else.)
>>>>>
>>>>> 2. I’d like to have a clearly documented lifecycle for beads. There
>>>>> are
>>>>> some standard bead types such as Model, Controller, View, Content
>>>>> View.
>>>>> When should each of these be created and how? At critical points in
>>>>> this
>>>>> cycle, things should happen automatically: The strand should pull from
>>>>> each bead which is added what interests it has.
>>>>>
>>>>> 3. At the point when all “necessary” beads are added, the beads should
>>>>> have some method automatically called so they can “finish” their
>>>>> setup if
>>>>> they rely on another bead.
>>>>>
>>>>> 4. All Strands should have a “notify” method that beads can call to
>>>>> let
>>>>> the strand know to let the appropriate beads know about an event. The
>>>>> beads should send a notification with the necessary payload if one is
>>>>> needed. Other beads can modify this payload and/or change the
>>>>> notification type if necessary. The publisher of the notification can
>>>>> examine the notification after it’s sent to know if it needs to do
>>>>> something different.
>>>>>
>>>>> Bonus points if there’s some kind of “post process” on notifications
>>>>> in
>>>>> case a bead needs to wait until after some other bead did their thing.
>>>>> This can take the form of a “registerPostProcess” call to the bead
>>>>> which
>>>>> is only every called once per registration.
>>>>>
>>>>> 5. I’m likely missing some points in the lifecycle…
>>>>>
>>>>> This is something that I’d work on if others think this makes any
>>>>> kind of
>>>>> sense. While a lot of this is not very different from how events are
>>>>> working today, it feels to me like it would help give the strand/bead
>>>>> relationships a lot more structure.
>>>>>
>>>>> Thoughts?
>>>>> Harbs
>>>>>
>>>>>>
>>>>>> On Jul 13, 2017, at 7:34 PM, Alex Harui <[hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>> Yes, that's how I think of it.  You are right that getting one bead
>>>>>> in a
>>>>>> multi bead set to listen to other beads is tricky.  UIBase defines a
>>>>>> particular order of model first, then view, then controller.  But
>>>>>> otherwise, you either have to dictate your own order or find another
>>>>>> event
>>>>>> to listen to that will give a bead another chance to search the
>>>>>> strand
>>>>>> for
>>>>>> other beads to listen to.  There is a "beadsAdded" event that can be
>>>>>> used.
>>>>>>
>>>>>> Maybe as more folks implement multi-bead sets we'll see patterns
>>>>>> emerge
>>>>>> and make it is simpler and faster.
>>>>>>
>>>>>> My 2 cents,
>>>>>> -Alex
>>>>>>
>>>>>> On 7/13/17, 3:54 AM, "Yishay Weiss" <[hidden email]> wrote:
>>>>>>
>>>>>>> Generally speaking it feels like sometimes I need to insure the
>>>>>>> order
>>>>>>> of
>>>>>>> invocation. Since beads communicate with one another through events
>>>>>>> it’s
>>>>>>> difficult to achieve. Regarding the upload response data I
>>>>>>> understand
>>>>>>> your suggestion as follows (edges contain event names):
>>>>>>>
>>>>>>> <Strand>--uploadRequested--<controllerForWithResponse (sends
>>>>>>> request)>---complete---<ModelWithResponse (after controller wrote to
>>>>>>> model>---modelChanged--<UserClassListening>
>>>>>>>
>>>>>>> And for the case where the user isn’t interested in the response,
>>>>>>> just
>>>>>>> in
>>>>>>> the status:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <Strand>---uploadRequested--<controllerForWithoutResponse>---complete
>>>>>>> ---
>>>>>>> <M
>>>>>>> odelWithoutResponse>--modelChanged--<UserClassListening>
>>>>>>>
>>>>>>> Is that right?
>>>>>>>
>>>>>>>
>>>>>>> From: Alex Harui<mailto:[hidden email]>
>>>>>>> Sent: Wednesday, July 12, 2017 9:58 AM
>>>>>>> To: [hidden email]<mailto:[hidden email]>
>>>>>>> Subject: Re: git commit: [flex-asjs] [refs/heads/develop] - Add
>>>>>>> FileUploaderWithResponseData
>>>>>>>
>>>>>>> I think I still don't understand.
>>>>>>>
>>>>>>> It is ok for beads to require other beads.  If a ResponseData bead
>>>>>>> requires a model with a slot for responseData and a controller that
>>>>>>> knows
>>>>>>> to record that data, that's how you are supposed to "re-compose"
>>>>>>> components.  There doesn't have to be one model or controller per
>>>>>>> component.  The strand is a gathering place for small pieces to work
>>>>>>> together.
>>>>>>>
>>>>>>> I'm not sure what work CheckPermissions needs to do, but is totally
>>>>>>> fine
>>>>>>> to split its work amongst a set of beads.
>>>>>>>
>>>>>>> HTH,
>>>>>>> -Alex
>>>>>>>
>>>>>>> On 7/11/17, 11:21 PM, "yishayw" <[hidden email]> wrote:
>>>>>>>
>>>>>>>> Ideally we wouldn't have to record data that's never read. This may
>>>>>>>> be an
>>>>>>>> extreme case, but some users will want to know the response on an
>>>>>>>> upload,
>>>>>>>> while some will just want to make sure the status is ok. I'd rather
>>>>>>>> not
>>>>>>>> anticipate too many use cases when writing the strand and the model
>>>>>>>> because
>>>>>>>> I might end up with code that's never used. If the bead was
>>>>>>>> responsible
>>>>>>>> for
>>>>>>>> both recording the response and exposing it to the user, we
>>>>>>>> wouldn't
>>>>>>>> have
>>>>>>>> to
>>>>>>>> do that.
>>>>>>>>
>>>>>>>> Perhaps a better example is permissions. I already have an Upload
>>>>>>>> bead.
>>>>>>>> Now
>>>>>>>> I want an alert to pop up if the user is not permitted to upload.
>>>>>>>> I'd
>>>>>>>> like
>>>>>>>> to be able to add a 'CheckPemissionsOnUpload' bead. Right now I
>>>>>>>> don't
>>>>>>>> see
>>>>>>>> how to do that, instead I would probably have to replace
>>>>>>>> 'UploadBead'
>>>>>>>> with
>>>>>>>> 'UploadButCheckPermissionsBead'. This takes us away from
>>>>>>>> composition
>>>>>>>> and
>>>>>>>> forces inheritance.
>>>>>>>>
>>>>>>>> Maybe we don't need to modify class definitions. I think it's
>>>>>>>> enough
>>>>>>>> to
>>>>>>>> modify the bead instance. In JS we could simply replace the
>>>>>>>> function,
>>>>>>>> and
>>>>>>>> in
>>>>>>>> flash we could maybe replace the whole original bead with a
>>>>>>>> flash.utils.Proxy. But this will make things a bit complicated to
>>>>>>>> read
>>>>>>>> and
>>>>>>>> maintain.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>>
>>>>>>>>
>>>>>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapac
>>>>>>>> he-
>>>>>>>> fl
>>>>>>>> e
>>>>>>>>
>>>>>>>>
>>>>>>>> x-development.2333347.n4.nabble.com%2FRe-git-commit-flex-asjs-refs-h
>>>>>>>> ead
>>>>>>>> s-
>>>>>>>> d
>>>>>>>>
>>>>>>>>
>>>>>>>> evelop-Add-FileUploaderWithResponseData-tp63051p63139.html&data=02%7
>>>>>>>> C01
>>>>>>>> %7
>>>>>>>> C
>>>>>>>>
>>>>>>>>
>>>>>>>> %7Cbd5414b3ced9495c188908d4c8f0f59b%7Cfa7b1b5a7b34438794aed2c178dece
>>>>>>>> e1%
>>>>>>>> 7C
>>>>>>>> 0
>>>>>>>>
>>>>>>>>
>>>>>>>> %7C0%7C636354384624691027&sdata=BGn1g0wbTZr7ikn3uuhcIGDGPEmSVWTwIF%2
>>>>>>>> Bla
>>>>>>>> F6
>>>>>>>> d
>>>>>>>> v8w%3D&reserved=0
>>>>>>>> Sent from the Apache Flex Development mailing list archive at
>>>>>>>> Nabble.com.
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>