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.

TreeNodes are generated for types that aren't actually components

See original GitHub issue

I’m not sure if this is actually a bug so feel free to correct me. I noticed that treehouse is generating TreeNodes for enums even when they’re not supposed to be used like a component in the view hierarchy. Here’s an example from Cash App:

// Enum:
@Node(3)
@Serializable
@SerialName("DialogAction")
data class DialogAction(...) : Action() {
  @Node(14)
  enum class ButtonStyle {
    @Property(1)
    STANDARD,

    @Property(2)
    DESTRUCTIVE,
  }

// Generated code:
public interface ButtonStyle<T : Any> : TreeNode<T> {
  public override fun apply(diff: PropertyDiff): Unit {
    when (val tag = diff.tag) {
      else -> throw IllegalArgumentException("Unknown tag $tag")
    }
  }
}

The generated node also becomes part of the NodeFactory. Other examples in our project include BoxLayout, BoxLayoutDirection, and BoxLayoutItem which are all inner classes of Box. Is this expected?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
saketcommented, Apr 7, 2021

I like it!

1reaction
JakeWhartoncommented, Apr 7, 2021

I’m moving the parser into its own module. Hold off for now.

@Node becomes @TypeId, but I was mulling @EntityId instead yesterday…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Everything you need to know about tree data structures
A tree is a collection of entities called nodes . Nodes are connected by edges . Each node contains a value or data...
Read more >
Primefaces Tree, TreeNode, TreeTable Example Tutorial
Each TreeNode has been created by passing two arguments; encapsulated data object instance and parent reference. Properties of every TreeNode ...
Read more >
Tree (data structure) - Wikipedia
In computer science, a tree is a widely used abstract data type that represents a hierarchical tree structure with a set of connected...
Read more >
Trees – Hacking with Swift+
Trees. Trees are an extraordinarily simple, extraordinarily useful data type, and in this article we'll make a complete tree data type using Swift...
Read more >
Simply Scheme: Introducing Computer Science ch 18: Trees
The components of a tree are called nodes. At the top is the root node of the tree; in the interior of the...
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