| /trunk/goverla/src/org/goverla/managers/PropertiesInvalidationManager.as r0 | /trunk/goverla/src/org/goverla/managers/PropertiesInvalidationManager.as r200 | ||
| 1 | package org.goverla.managers | ||
|---|---|---|---|
| 2 | { | ||
| 3 | import mx.rpc.AsyncDispatcher; | ||
| 4 | |||
| 5 | import org.goverla.interfaces.IPropertiesInvalidable; | ||
| 6 | |||
| 7 | public class PropertiesInvalidationManager | ||
| 8 | { | ||
| 9 | public static function get instance() : PropertiesInvalidationManager | ||
| 10 | { | ||
| 11 | if (_instance == null) | ||
| 12 | { | ||
| 13 | _instance = new PropertiesInvalidationManager(); | ||
| 14 | } | ||
| 15 | return _instance; | ||
| 16 | } | ||
| 17 | |||
| 18 | private static var _instance : PropertiesInvalidationManager; | ||
| 19 | |||
| 20 | public function invalidateProperties(target : IPropertiesInvalidable) : void | ||
| 21 | { | ||
| 22 | if (_targets.indexOf(target) < 0) | ||
| 23 | { | ||
| 24 | _targets.push(target); | ||
| 25 | |||
| 26 | if (_dispatcher == null) | ||
| 27 | { | ||
| 28 | _dispatcher = new AsyncDispatcher(commitProperties, [], 0); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | public function commitProperties() : void | ||
| 34 | { | ||
| 35 | for each (var target : IPropertiesInvalidable in _targets) | ||
| 36 | { | ||
| 37 | target.commitProperties(); | ||
| 38 | } | ||
| 39 | _targets = []; | ||
| 40 | _dispatcher = null; | ||
| 41 | } | ||
| 42 | |||
| 43 | private var _needInvalidation : Boolean; | ||
| 44 | |||
| 45 | private var _targets : Array = []; | ||
| 46 | |||
| 47 | private var _dispatcher : AsyncDispatcher; | ||
| 48 | |||
| 49 | } | ||
| 50 | } | ||