Set expression position

69 views
Skip to first unread message

Yuri Sulyma

unread,
Jan 22, 2025, 10:08:29 AMJan 22
to desmos-api-discuss
In the API, how do I insert a new expression between two existing expressions? setExpression() always appends to the list of expressions. I can work around this by using setState(), but that is very heavy-handed.

Thanks

U ji

unread,
Mar 18, 2025, 6:05:12 AMMar 18
to desmos-api-discuss
Not sure if this is the right way to do it, but this code works fine.

Calc.controller.dispatch({
  type: "insert-item-at-index",
  state: {
    id: Calc.controller.generateId(),
    type: "expression",
    latex: "a=1"
  },
  index: 2
})

2025年1月23日木曜日 0:08:29 UTC+9 Yuri Sulyma:

Chris Lusto

unread,
Apr 14, 2025, 10:44:46 AMApr 14
to desmos-api-discuss
There is currently no supported way to set the expression order through the API. We caution people against manipulating states before passing them to `.setExpression()`, as they're intended to be opaque; and accessing the controller like this is also not supported. Your code should not rely on the controller name, or the specifics of what we dispatch (or the fact that we use a Flux architecture at all). Those are implementation details that are not part of the API contract and can change in breaking ways without notice.
Reply all
Reply to author
Forward
0 new messages