Results 1 to 2 of 2

Thread: Publishing from components with a ViewModel

  1. #1
    Sencha Premium User
    Join Date
    Oct 2016
    Posts
    6
    Answers
    1

    Question Publishing from components with a ViewModel

    I'm looking for suggestions on how best to publish state from a component that has a ViewModel.

    My goal is to create a component that can publish state (akin to a textfield). I want to be able to include my new component in a parent container with a ViewModel, give my new component a reference, and expect "<my-comp-reference>.<published-value>" to be available in the parent ViewModel.

    This works as expected when my child component does not have a ViewModel, However, when it does, any state publishing from the child is swallowed by the child view model (and as per the arrows in ViewModelInternals isn't visible in the parent).

    I suppose a loose expectation is that any published state is available from a reference-holding-parent-container's ViewModel?

    How may I achieve this or is there a suitable alternative structure? I've created a fiddle here to describe the question https://fiddle.sencha.com/#view/editor&fiddle/1ruv

    Thanks.

  2. #2
    Sencha Premium User
    Join Date
    Oct 2016
    Posts
    6
    Answers
    1

    Default

    I've updated the fiddle with a solution, didn't fork so the original has gone.

    I happened to be looking over the kitchen sink modern components when I saw this example which happened to demonstrate the problem I was having http://examples.sencha.com/extjs/6.2...#default-gauge

    In this case, the slider is the "publishing" component and the two bars are bound to the value. I noticed that the slider was also bound, and that was the means by which it was publishing value.

    The updated fiddle is here https://fiddle.sencha.com/#view/editor&fiddle/1ruv . The observation that I'll be working with when it comes to viewmodels is that you should aim to "inherit down, bind up" when passing data up and down the view hierarchy.

Similar Threads

  1. [OPEN] Binding ViewModel to stateful components
    By sytel in forum Ext JS 6.x Bugs
    Replies: 5
    Last Post: 18 Aug 2019, 11:24 AM
  2. [FIXED] Widget column sub-components don't inherit the ViewModel
    By Trevor4001 in forum Ext JS 6.x Bugs
    Replies: 2
    Last Post: 7 Oct 2016, 8:10 PM
  3. Binding ViewModel to stateful components
    By sytel in forum Sencha Ext JS Q&A
    Replies: 0
    Last Post: 21 Oct 2015, 2:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •