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.

Nested Update/Effects

See original GitHub issue

Have you considered this:

app({
	update: {
		example: {
			attempt: () => alert(1)
		}
	}
})

It should then be possible to call msg.example.attempt().


Meanwhile I ended up using this
const convert = (actions, prefix = '') => Object
	.keys(actions)
	.map(name => typeof actions[name] === 'function'
		? ({[`${prefix[0].toLowerCase()}${prefix.slice(1)}${name[0].toUpperCase()}${name.slice(1)}`]: actions[name]})
		: (convert(actions[name], `${prefix}${name[0].toUpperCase()}${name.slice(1)}`))
	)
	.reduce((a, b) => Object.assign(a, b), {})

app({
	update: convert({
		example: {
			attempt: () => alert(1)
		}
	})
})

This maps example.attempt to exampleAttempt.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
FlorianWendelborncommented, Feb 10, 2017

@selfup This is possible though:

app({
	update: {
		...red,
		...blue,
		...yellow
	}
})
2reactions
selfupcommented, Feb 10, 2017
const red = require("./red-effects")
const blue = require("./blue-effects")
const yellow = require("./yellow-effects")

app({
  update: { red, blue, yellow }
})

Now there is no naming conflict but it is no longer flat 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.awt.IllegalComponentStateException when nested ...
If I pass state = WindowState(width = 1000.dp, height = 1000.dp) into a Window I get the following exception when it's recomposed: Exception ......
Read more >
View.UpdateEffect
Construct the effect that is returned by the command handler. The effect describes next processing actions, such as emitting events and sending a...
Read more >
Visualizing Nested and Cross Random Effects - Josh Errickson
Whether random effects are nested or crossed is a property of the data, not the model. However, when fitting the model, effects can...
Read more >
BeaconMenu (forge 1.18.2-40.1.51)
Nested Class Summary. Nested Classes. Modifier and Type. Class. Description ... stillValid(Player p_39047_). void. updateEffects(int p_39054_, int p_39055_) ...
Read more >
Logistic-Tropical Decompositions and Nested Subgraphs
to nested subgraphs, i.e. graphs whose adjacency matrix is nested. ... e function UpdateFactors (Line 8) follows the SGD approach.
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