Comments (5)
Hi!
Using Beagle.add()
(without remove()
) should be a good solution, if you have constant ID-s for all of the modules. (Every module has an id
parameter in its constructor, but that's optional - by default it's a random string, that's why the animation glitches happened).
Another approach would be to find the modules that are already added using Beagle.find()
and change their values. A bit cumbersome but it looks like this:
internal fun createTestSection() = listOf(
TextModule(
text = "Test",
type = TextModule.Type.SECTION_HEADER
),
SingleSelectionListModule(
id = "test_single_selection",
title = "Single selection list",
items = listOf(
TestDataItem("A"),
TestDataItem("B"),
TestDataItem("C"),
),
initiallySelectedItemId = "A"
),
CheckBoxModule(
id = "checkbox_1",
text = "Feature flag 1"
),
CheckBoxModule(
id = "checkbox_2",
text = "Feature flag 2"
),
TextModule(
text = "Reset all flags",
type = TextModule.Type.BUTTON,
onItemSelected = {
Beagle.find<SingleSelectionListModule<TestDataItem>>("test_single_selection")?.setCurrentValue(Beagle, "A")
Beagle.find<CheckBoxModule>("checkbox_1")?.setCurrentValue(Beagle, false)
Beagle.find<CheckBoxModule>("checkbox_2")?.setCurrentValue(Beagle, false)
}
),
)
private data class TestDataItem(val identifier: String) : BeagleListItemContract {
override val id = identifier
override val title = "Item $identifier".toText()
}
Let me know if it helps!
Edit: if you ever want to save the states of modules to shared preferences using the isValuePersisted
parameter, you must set a constant ID.
from beagle.
Thanks!
I have a static id and use Beagle.add()
without remove()
, but it work good until you set value from debug panel than UI state does not change (only after application restart). Can be bug?
If use Beagle.find()
all good!
from beagle.
I double-checked the functionality and couldn't see any issues. Could you provide more details, maybe code examples?
from beagle.
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
Beagle.add(
*mutableListOf<Module<*>>().apply {
addAll(headerComponent.invoke())
add(DividerModule("headerDivider"))
addAll(featuresComponent.invoke(application, it))
add(DividerModule("featuresDivider"))
}.toTypedArray()
)
}
Understood, more details:
First case:
- Open menu
- Switch SingleSelectionListModule item
- Clicked on the data reset so that a new value comes to subscribe
- menu has not been updated
- Restart app
- menu has been updated
But second case:
- Open menu
- Switch SingleSelectionListModule item
- Restart app
- Clicked on the data reset so that a new value comes to subscribe
- menu has been updated
from beagle.
Correction, I started using the Switch Module, the problem is the same.
The value does not change if the value was changed earlier by switching through the UI menu. If you do not switch manually, through the ui, then everything is updated correctly
from beagle.
Related Issues (20)
- NoSuchMethodError somewhere in Beagle.initialize() after moving to Hilt HOT 4
- Coil update HOT 3
- TextInputModule Crash HOT 2
- On SDK 31 and above the screen recording crashes when started HOT 1
- Beagle crash logging doesn't work HOT 2
- Crash with DrawerLayout when getting permissions HOT 3
- Drawer doesn't appear when using content.viewTreeObserver.addOnPreDrawListener on the Acitivty HOT 5
- Beagle should not cause a crash if a value is set to the Slider module that is outside the specified range HOT 1
- The drawer opening gesture does not respect the value of `shouldShowDebugMenu` HOT 1
- Can't open Activity when try to forceCrash from debug panel HOT 7
- ListModules should support the isEnabled flag.
- TextInputModule. Suggestion for improving the validator
- Buggy inset handling in edge-to-edge apps
- Double debug-panel HOT 3
- When activity theme is not a material theme, Beagle view crashes. HOT 3
- Implement dynamic notification permission support HOT 1
- Support for Beagle on Jetpack Compose? HOT 7
- Possibility to change the width of the drawer HOT 2
- The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beagle.