Skip to main content
Tweeted twitter.com/StackMagento/status/947128633579237376
Fix typo
Source Link
Ben Crook
  • 15.7k
  • 4
  • 52
  • 105

I understand how to use imports: {} and exports: {} to share a UI components properties, such as:

defaults: {
    exports: {
        shouldShowMessage: '${$.component}'
    }
}

Which returns the component name in the exports.

enter image description here

But when I try to export a Knockout observable it is always undefined:

defaults: {
    exports: {
        shouldShowMessage: '${$.shouldShowMessage}'
    }
}

...

setupKoBindings: function() {
    this.shouldShowMessage = ko.observable('Testing');
}

enter image description here

As a workaround I am going to create a storage modalmodel as explained here but I would prefer to use the imports and exports.

I understand how to use imports: {} and exports: {} to share a UI components properties, such as:

defaults: {
    exports: {
        shouldShowMessage: '${$.component}'
    }
}

Which returns the component name in the exports.

enter image description here

But when I try to export a Knockout observable it is always undefined:

defaults: {
    exports: {
        shouldShowMessage: '${$.shouldShowMessage}'
    }
}

...

setupKoBindings: function() {
    this.shouldShowMessage = ko.observable('Testing');
}

enter image description here

As a workaround I am going to create a storage modal as explained here but I would prefer to use the imports and exports.

I understand how to use imports: {} and exports: {} to share a UI components properties, such as:

defaults: {
    exports: {
        shouldShowMessage: '${$.component}'
    }
}

Which returns the component name in the exports.

enter image description here

But when I try to export a Knockout observable it is always undefined:

defaults: {
    exports: {
        shouldShowMessage: '${$.shouldShowMessage}'
    }
}

...

setupKoBindings: function() {
    this.shouldShowMessage = ko.observable('Testing');
}

enter image description here

As a workaround I am going to create a storage model as explained here but I would prefer to use the imports and exports.

Source Link
Ben Crook
  • 15.7k
  • 4
  • 52
  • 105

How to share Knockout JS observables between UI Components

I understand how to use imports: {} and exports: {} to share a UI components properties, such as:

defaults: {
    exports: {
        shouldShowMessage: '${$.component}'
    }
}

Which returns the component name in the exports.

enter image description here

But when I try to export a Knockout observable it is always undefined:

defaults: {
    exports: {
        shouldShowMessage: '${$.shouldShowMessage}'
    }
}

...

setupKoBindings: function() {
    this.shouldShowMessage = ko.observable('Testing');
}

enter image description here

As a workaround I am going to create a storage modal as explained here but I would prefer to use the imports and exports.