Краткое введение в Mate Flex framework

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Краткое введение в Mate Flex framework - Presentation Transcript

    1. Краткое введение в Mate Flex framework Константин Ковалёв http://riapriority.com/ [email_address] 24 августа 2008 г.
    2. Как это выглядит? http://mate.asfusion.com/ М á тэ
    3. Немного фактов
      • Публичное появление 4 мая 2008
      • Альфа
      • Использовался в проектах AsFusion
      • Текущая версия 0.7.5
      • http://mate-framework.googlecode.com/svn/trunk/src
      • Apache License, Version 2.0
    4. Особенности
      • СОБЫТИЯ!
        • «Родная» событийная модель
      • Декларативный синтаксис
      • Dependency injection
      • Связывание данных
      • Используются сильные стороны Flex !
      • Это не микроархитектура – это framework !
      • Синглтонов – нет!
    5. Использование
      • http://mate.asfusion.com/page/documentation/getting-started
    6. 1 . Главный файл приложения
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Application
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns=&quot;*&quot;>
      • <MainEventMap />
      • <MainUI />
      • </mx:Application>
    7. 2. Событие
      • package
      • {
        • import flash.events.Event;
        • public class TestEvent extends Event
        • {
          • public static const BUTTON_CLICK:String = &quot;buttonClick&quot;;
          • public function TestEvent(type:String,
          • bubbles:Boolean = true , cancelable:Boolean=false)
          • {
          • super(type, bubbles, cancelable);
          • }
        • }
      • }
    8. 3. Класс представления
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Box
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:Dispatcher
      • id=&quot;clickDispatcher&quot;
      • generator=&quot;{TestEvent}&quot;
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot; />
      • <mx:Button
      • label=&quot;Click Me!&quot;
      • click=&quot; clickDispatcher.generateEvent() &quot; />
      • </mx:Box>
    9. 3. Класс представления ( old style )
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Box
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mx:Button
      • label=&quot;Click Me!&quot;
      • click=&quot; dispatchEvent(new TestEvent (TestEvent.BUTTON_CLICK) &quot; />
      • </mx:Box>
    10. 4. EventMap
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mate:EventMap
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:EventHandlers
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <SomeAction />
      • </mate:EventHandlers>
      • </mate:EventMap>
    11. 5. Model
      • package
      • {
      • public class ClickManager
      • {
      • [Bindable]
      • public var clickNumber:int = 0;
      • public function performClick ():void
      • {
      • clickNumber ++;
      • }
      • }
      • }
    12. 4. EventMap из реальной жизни (почти  )
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mate:EventMap
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:EventHandlers
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:MethodInvoker
      • generator=&quot;{ClickManager}&quot;
      • method=&quot;performClick&quot; />
      • </mate:EventHandlers>
      • </mate:EventMap>
    13. 3. Класс представления (из реальной жизни  )
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Box
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:Dispatcher
      • id=&quot;clickDispatcher&quot;
      • generator=&quot;{TestEvent}&quot;
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot; />
      • <mx:Number
      • id=&quot;clickNumber&quot; />
      • <mx:Button
      • label=&quot;Click Me!&quot;
      • click=&quot;clickDispatcher.generateEvent()&quot; />
      • <mx:Label
      • text=&quot;{clickNumber}&quot; />
      • </mx:Box>
    14. 4. EventMap ( финальный аккорд )
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mate:EventMap
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:EventHandlers
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:MethodInvoker
      • generator=&quot;{ClickManager}&quot;
      • method=&quot;performClick&quot; />
      • </mate:EventHandlers>
      • <mate:Injectors
      • target=&quot;{MainUI}&quot;>
      • <mate:PropertyInjector
      • source=&quot;{ClickManager}&quot;
      • sourceKey=&quot;clickNumber&quot;
      • targetKey=&quot;clickNumber&quot; />
      • </mate:Injectors>
      • </mate:EventMap>
    15. Общая картина MainUI MainEventMap ClickManager
    16. Общая картина MainUI MainEventMap ClickManager TestEvent.BUTTON_CLICK
    17. Общая картина MainUI MainEventMap ClickManager performClick () TestEvent.BUTTON_CLICK
    18. Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK
    19. Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK Model Controller View
    20. Разделяем контроллер и Dependency injection
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Application
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns=&quot;*&quot;>
      • <MainEventMap />
      • <MainUI />
      • <ModelMap />
      • </mx:Application>
    21. Разделяем контроллер и Dependency injection
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <!-- ModelMap -->
      • <mate:EventMap
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:Injectors
      • target=&quot;{MainUI}&quot;>
      • <mate:PropertyInjector
      • source=&quot;{ClickManager}&quot;
      • sourceKey=&quot;clickNumber&quot;
      • targetKey=&quot;clickNumber&quot; />
      • </mate:Injectors>
      • </mate:EventMap>
    22. Взаимодействие с сервером MainUI MainEventMap Server
    23. Взаимодействие с сервером MainUI MainEventMap Server TestEvent.BUTTON_CLICK
    24. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK
    25. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++
    26. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber
    27. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber clickNumber
    28. Идем на сервер
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mate:EventMap
      • xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
      • xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mate:EventHandlers
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:RemoteObjectInvoker
      • destination=&quot;someDestination&quot;
      • method=&quot;performClick&quot;>
      • <mate:resultHandlers>
      • <mate:ServiceResponseAnnouncer
      • type=&quot;result&quot; />
      • </mate:resultHandlers>
      • </mate:RemoteObjectInvoker>
      • </mate:EventHandlers>
      • </mate:EventMap>
    29. Видоизмененный View
      • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
      • <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;>
      • <mx:Script>
      • <![CDATA[
      • import com.asfusion.mate.events.ResponseEvent;
      • [Bindable]
      • public var clickNumber:Number = 0;
      • private function onResult (event:ResponseEvent):void {
      • clickNumber = Number (event.result);
      • }
      • ]]>
      • </mx:Script>
      • <mate:Dispatcher id=&quot;clickDispatcher” generator=&quot;{TestEvent}” type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:ServiceResponseHandler
      • result=&quot;onResult(event)&quot; />
      • </mate:Dispatcher>
      • <mx:Button label=&quot;Click Me!” click=&quot;clickDispatcher.generateEvent()&quot; />
      • <mx:Label text=&quot;{clickNumber}&quot; />
      • </mx:Box>
    30. Передача параметров
    31. Видоизмененное событие
      • package
      • {
      • import flash.events.Event;
      • public class TestEvent extends Event {
      • public static const BUTTON_CLICK:String = &quot;buttonClick&quot;;
      • public var amount:int;
      • public function TestEvent(type:String,
      • bubbles:Boolean=true, cancelable:Boolean=false) {
      • super(type, bubbles, cancelable);
      • }
      • }
      • }
    32. Параметр во View
      • <mx:Number
      • id=&quot;currentAmount&quot;>1</mx:Number>
      • <mx:RadioButtonGroup id=&quot;amountGroup&quot;
      • change=&quot;currentAmount = event.currentTarget.selection.data&quot; />
      • <mx:RadioButton
      • group=&quot;{amountGroup}“
      • selected=“true”
      • data=&quot;1&quot;
      • label=&quot;1&quot; />
      • <mx:RadioButton
      • group=&quot;{amountGroup}&quot;
      • data=&quot;2&quot;
      • label=&quot;2&quot; />
    33. Рассылка события из View
      • <mate:Dispatcher
      • id=&quot;clickDispatcher&quot;
      • generator=&quot;{TestEvent}&quot;
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:eventProperties>
      • <mate:EventProperties
      • amount=&quot;{currentAmount}&quot; />
      • </mate:eventProperties>
      • </mate:Dispatcher>
      • <mx:Number
      • id=&quot;currentAmount&quot;>1</mx:Number>
    34. Отсылка параметра на сервер
      • <mate:EventHandlers
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • <mate:RemoteObjectInvoker
      • destination=&quot;someDestination&quot;
      • method=&quot;performClick &quot;
      • arguments=&quot;{event.amount}&quot; >
      • <mate:resultHandlers>
      • <mate:ServiceResponseAnnouncer
      • type=&quot;result&quot; />
      • </mate:resultHandlers>
      • </mate:RemoteObjectInvoker>
      • </mate:EventHandlers>
    35. EventMap: SmartObject
      • event
      • resultObject
      • fault
      • lastReturn
      • message
      • data
      • scope
      • currentEvent
      <mate:RemoteObjectInvoker destination=&quot;someDestination“ method=&quot;performClick “ arguments=&quot;{ event.amount }&quot;> … </mate:RemoteObjectInvoker>
    36. Хитрости SmartObject
      • Можно:
        • arguments=“{event.count}”
      • Нельзя:
        • arguments=“{event.count + 1 }”
        • arguments=“{event.book.id}”
        • итд.
      • Можно использовать MethodInvoker
    37. Отладка
      • <mate:Debugger
      • level=&quot;{Debugger.DEBUG}&quot; />
      • <mate:EventHandlers
      • debug=&quot;true&quot;
      • type=&quot;{TestEvent.BUTTON_CLICK}&quot;>
      • Не забывайте убирать после отладки: жрет ресурсы!
    38. Взаимодействие с сервером
      • RemoteObjectInvoker
      • HTTPServiceInvoker
      • WebServiceInvoker
      • Производные от ServiceInvoker > AbstractServiceInvoker
      • При создании своего сервиса:
        • implements IAction
    39. Собственные обработчики
      • implements IAction
      • Можно унаследоваться от AbstractAction
    40. Ресурсы
      • http://mate.asfusion.com/page/documentation
      • http://mate.asfusion.com/api_docs
      • http://mate.asfusion.com/page/downloads
      • http://mate.asfusion.com/page/examples
    41. Mate+Cairngorm= ♥
      • http://mate.asfusion.com/page/examples/cafe-townsend
    42. Пример Ozon Book Finder
    43. Q&A
      • Константин Ковалёв
      • http://riapriority.com/
      • [email_address]

    + ConstantinerConstantiner, 2 years ago

    custom

    1408 views, 1 favs, 1 embeds more stats

    Доклад Константина Ковалёв more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1408
      • 1284 on SlideShare
      • 124 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 13
    Most viewed embeds
    • 124 views on http://riapriority.com

    more

    All embeds
    • 124 views on http://riapriority.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?