question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Objects as attributes?

See original GitHub issue

Are components just fancy element wrappers or am I supposed to be able to pass richer forms of data through the parameters?

This is with v1 moon, and a slightly modified monx (just so that it is compatible?? with v1) https://github.com/LeviSchuck/moon-rerender In this reduced example, I have a list of related buttons which are populated dynamically. I would like the prompt component to make the buttons based on an input array of simple button-detail-objects {label:'text here', key:'code-thing-here'} However, instead it seems to be casted to a string like [Object, Object ..] I looked up some old vue stuff and they suggested using JSON stringify and parse between things which seems so incredibly distasteful.

from index.html

<prompt m-if="store.state.pendingPrompts" options="{{store.state.prompts}}"></prompt>

from scripts.js

const store = new Monx({
  state: {
    pendingAgree: true,
    agreeText: "Yes",
    // normally []
    prompts: [{
      label: "Adam Jensen",
      scene: "adam"
    }, {
      label: "JC Denton",
      scene: "jc"
    }],
    // normally false
    pendingPrompts: true,
  },
...
}

Of additional note, when I dispatch to monx and change the agreeText, the button is not updated to reflect this. However when pendingAgree is updated within a dispatch action, the m-if attribute behaves as expected and will hide the button.

<c-button m-if="store.state.pendingAgree" m-on:click="agree" content="{{store.state.agreeText}}"></c-button>
  1. Is there any way to pass structured data, or is everything a string?
  2. How come m- attributes re-render but others do not re-render? Is this an artifact of monx and moon?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LeviSchuckcommented, Sep 9, 2017

Nevermind, this was an error on my part, it works just fine 😉

0reactions
LeviSchuckcommented, Sep 9, 2017

Indeed m-literal:options (where options is my custom property) does the job! At least initially.

I have updated my reduced example repo. https://github.com/LeviSchuck/moon-rerender

There are two versions, one using the template stuff, and one using a direct render function. They both behave the same, so I think I got whatever right inside the render function.

The button’s content does change when the monx store’s object changes, and it does hide correctly too. But the prompt button list never updates / re-renders when the corresponding monx store object updates.

Clicking on the agree button dispatches a replacement set of button descriptions (in scripts.js) for the prompt list to render–but it seems the render function is not called again on the prompt list…

Am I missing something on the component itself?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attributes and properties of objects - IBM
An object characteristic that is always present and occupies storage, even if the attribute does not have a value. In this respect, an...
Read more >
Objects with Attributes
An object is represented by a set of attributes, which can be read and used by non-Java applications from the directory. The same...
Read more >
Define objects and their attributes with classes
Use a class as a template for your future objects. In a class, define the name and type of some variables. In Java,...
Read more >
Objects as attributes - Python Programming MOOC 2021
A list of objects as an attribute of an object. In the examples above we used single instances of other classes as attributes:...
Read more >
What is the difference between an attribute and an object?
+ 1. An object is an instance of a class (class is like a blue print, like a description of the parts of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found