# How to update nodeview from outside

**URL:** <https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660>\
**Category:** Uncategorized\
**Created:** [April 3, 2021, 11:47am UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660 "2021-04-03T11:47:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [April 3, 2021, 11:47am UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660/1 "2021-04-03T11:47:42Z")

</div>

```javascript
let nodeViews = [];

let editor = new EditorView( this._editor_show_el , {

    state: EditorState.create({
        doc: doc,
    }),

    nodeViews: {

        'mainbody'(node, view, getPos) {

            let obj = new MainbodyView(node, view, getPos, {
            });

            nodeViews.push(obj);

            return obj;
        }

    },

});

setTimeout(x => {

  console.log('nodeViews[0]', nodeViews[0]);
  // update it
  nodeViews[0].update_jsmind('ac');

}, 1000);

```

At present, I do like this, which can realize my needs, but if it is multi person real-time cooperation, it will not work well

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [April 6, 2021, 12:27pm UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660/2 "2021-04-06T12:27:36Z")

</div>

Node decorations can be used to pass information to node views (though those are also not the easiest thing to set up). I think there is a need for some imperative way to force node views to redraw, but I’m not sure what it would look like yet.

For you, would a view method that broadcasts a given object to all node views in the document (allowing them to run their own update logic, and possibly opt to be redrawn entirely through a return value) work?

---

<div class="post-metadata">

**Author:** ![milu2003](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/milu2003/32/2063_2.png) [@milu2003](https://discuss.prosemirror.net/u/milu2003)\
**Post date:** [April 6, 2021, 10:39pm UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660/3 "2021-04-06T22:39:29Z")

</div>

Node decorations may not be enough

My requirement is that there is a Mind map component in nodeview, and the interface inside can be updated from the outside when multiple people collaborate in real time.

At present, it is achievable but not elegant

Demo video :

[https://user-images.githubusercontent.com/15957433/113650038-2431d700-96c2-11eb-89b6-450c31c551e0.mov](https://user-images.githubusercontent.com/15957433/113650038-2431d700-96c2-11eb-89b6-450c31c551e0.mov)

---

<div class="post-metadata">

**Author:** ![prosed](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@prosed](https://discuss.prosemirror.net/u/prosed)\
**Post date:** [November 19, 2023, 1:14am UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660/4 "2023-11-19T01:14:14Z")

</div>

@marijin was such an imperative approach ever implemented? Right now we have to do weird things to update the NodeView like scan the document for the nodes that need updating and set a dummy attribute. It would be wonderful to have imperative updates.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 19, 2023, 3:17pm UTC](https://discuss.prosemirror.net/t/how-to-update-nodeview-from-outside/3660/5 "2023-11-19T15:17:19Z")

</div>

No. Having node views that are stateful (beyond the node and decorations they get), is problematic in general—they may be redrawn and lose their state, when content around them changes.
