Child pages
  • Component (child) property type

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleThe model change listener
Object.defineProperty($scope.myComponentProperty.model, $sabloConstants.modelChangeNotifier,
                         { configurable: true, value: function(property,value) {

                switch(property) {
                    case "borderType":
                        (...)
                        break;
                    case "background":
                    case "transparent":
                        (...)
                        break;
(...) 

 


Advanced usage of non-foundset-linked components

...

In Servoy < 8.4, you might find what $foundsetTypeUtils provides useful depending on how you plan on using this listener. Starting with 8.4 granular updates are easier to use and you don't need to process those indexes anymore before using them. See comments above.

Note
titleAlways make sure to remove listeners when the component is destroyed


It is important to remove the listeners when your component's scope is destroyed. For example if due to a tabpanel switch of tabs your form is hidden, the component and it's angular scope will be destroyed - at which point you have to remove any listeners that you added on model properties (like the child component property), because the model properties will be reused in the future (for that form when it is shown again) and will keep any listeners in it. When that form will be shown again, it's UI will get recreated - which means your (new) component will probably add the listener again.

If you fail to remove listeners on $scope destroy this will lead to memory leaks (model properties will keep listeners of obsolete components each time that component's form is hidden, which in turn will prevent those scopes and other objects that they can reference from being garbage collected) and probably weird exceptions (obsolete listeners executing on destroyed scopes of destroyed components).

Example of removing a listener:

Code Block
languagejs
titleHow to remove listeners on scope destroy
			$scope.$on("$destroy", function() {
				if (l && $scope.model.myComponentThatIsFoundsetLinked) $scope.model.myComponentThatIsFoundsetLinked.removeViewportChangeListener(l);
			});


Runtime property access

Since Servoy 8.0.3 , component type is scriptable. Type can be accessed like: 

...