MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / bind

Function bind

packages/core/ui/core/view-base/index.ts:895–922  ·  view source on GitHub ↗
(options: BindingOptions, source: Object = defaultBindingSource)

Source from the content-addressed store, hash-verified

893 private bindingContextBoundToParentBindingContextChanged: boolean;
894
895 public bind(options: BindingOptions, source: Object = defaultBindingSource): void {
896 const targetProperty = options.targetProperty;
897 this.unbind(targetProperty);
898
899 if (!this.bindings) {
900 this.bindings = new Map<string, Binding>();
901 }
902
903 const binding = new Binding(this, options);
904 this.bindings.set(targetProperty, binding);
905
906 let bindingSource = source;
907 if (bindingSource === defaultBindingSource) {
908 bindingSource = this.bindingContext;
909 binding.sourceIsBindingContext = true;
910 if (targetProperty === 'bindingContext') {
911 this.bindingContextBoundToParentBindingContextChanged = true;
912 const parent = this.parent;
913 if (parent) {
914 parent.on('bindingContextChange', this.bindingContextChanged, this);
915 } else {
916 this.shouldAddHandlerToParentBindingContextChanged = true;
917 }
918 }
919 }
920
921 binding.bind(bindingSource);
922 }
923
924 public unbind(property: string): void {
925 const bindings = this.bindings;

Callers

nothing calls this directly

Calls 4

bindMethod · 0.95
unbindMethod · 0.80
onMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected