Thanks for including the test part. That's always missing in dev videos!
@PhilippLackner2 жыл бұрын
Glad to help!
@lalobarrios162 жыл бұрын
Hi Phil, Thank you for this great content. Just a quick revision when you do the following: if(hasError) { state = state.copy( emailError = emailResult.errorMessage, passwordError = passwordResult.errorMessage, repeatedPasswordError = repeatedPasswordResult.errorMessage, termsError = termsResult.errorMessage ) return } The state should be modified regardless of an error here. While I was watching the video at the end you get the toast and the emailError is still not null because of hasError being false. So the state modification should get extracted out of that block and placed before the hasError check: state = state.copy( emailError = emailResult.errorMessage, passwordError = passwordResult.errorMessage, repeatedPasswordError = repeatedPasswordResult.errorMessage, termsError = termsResult.errorMessage ) if(hasError) { return }
@yasserakbbach73422 жыл бұрын
Nice catch 👌
@PhilippLackner2 жыл бұрын
Correct, thanks :)
@abdremo2 жыл бұрын
@s-w2 жыл бұрын
I prefer to create an after text changed listener on the edit texts that saves all the edit texts each time any text is changed. All the text is then tested in the use case and the returned messages are reviewed within the UI with a "when" bracket that will only show one message at a time. When there are no messages to show, the last option in the "when" bracket will enable the button to be clickable.
@Rafael-hk9pg Жыл бұрын
So you change the state based on the message and not on a Event.. ?
@s-w Жыл бұрын
The state changes any time any of the edit texts change. If there's an issue, the variable in the state for that edit text will have a message or it will be null if it passes the chack. So the when statement will stop at the first variable with a message and do what you want it to do in that instance. If there are only nulls remaining in the state, the else branch in the when statement can make the confirm button enabled. But you have to make sure to make it disabled each time the text changes until all the data is validated.
@AfriandiHaryanto2 жыл бұрын
One of my favorites about kotlin is, its Sealed Class. And I think it suits best for this kind of case. I created sealed class with children of every possible outcome, make domain layer don't care about wording and let presentation layer map it.
@PhilippLackner2 жыл бұрын
I love it too
@AfriandiHaryanto2 жыл бұрын
@@PhilippLackner Wow, it's an honor to get replied by you. 😂 I had been watching many of your videos to learn android..
@rileyfarro68012 жыл бұрын
You speak calmly and you remind me of Bob Ross, but showing expertise in Android development. What a great video 😁
@PhilippLackner2 жыл бұрын
Hahaha thanks mate!
@StevdzaSan2 жыл бұрын
Nice video bro 👌 I like the use of Channels, they seem quite good in a combination with Compose.
@PhilippLackner2 жыл бұрын
Thanks bud! Yeah it's the only real way to receive events in the composable (other than SharedFlow)
@ChrisCologne848 ай бұрын
@@PhilippLackner Why you use a Channel and not a StateFlow or mutableStateOf?
@arielapp94692 жыл бұрын
Great video. Regarding unit testing, isn't it better to use interface impl pair for the use cases? Also, when asserting values, when you use assertEquals, the first parameter should be the value you expect, and the second value should be the value that you test. Regardless, when you test booleans, you can use assertTrue and assertFalse.
@Ayor887 ай бұрын
I've mix this video and the "This Is My FAVORITE Error Handling Class" one to valid custom user input and it work greats !
@sh3r1p492 жыл бұрын
Another quality tutorial from Phillip! Thank you man!
@sebastianpalm349511 ай бұрын
really really good video one gently critic the error message should disappear when the user is editing the input field. Thanks a lot for the video!! :))
@matt-g-recovers2 жыл бұрын
We should step into DDD with a solid Use Case in MVVM, then convert to vertical slice architecture with a few independently buildable and testable modules...then we are styling Phil.
@emmanuelpregnolato50262 жыл бұрын
Excellent as always. We could add on the TextFields a maxLines = 1 and singleLine = true otherwise we could have many lines or an ' '
@adriencuisse96412 жыл бұрын
Setting error messages in the use case is definitely not clean architecture, interactor response should only contains litterals like boolean error flags, the presenter is responsible for error strings, and it's not in application layer.
@radbaver2 жыл бұрын
Super PRO Champions League content Phillipp! Thanks!!
@bajrangchapola67482 жыл бұрын
Great content again. Thanks for making such wonderful video. Complete this video by making network call handling success and failure case. How to propagate error to UI .
@06rokib4 ай бұрын
What is the way to make the error messages support translation? Context can not be passed in use cases since these are designed to be independent of the platform.
@mr-re1ax Жыл бұрын
Duuuuuuude! This is supper cool example! Respect!!!
@Rafael-hk9pg Жыл бұрын
How do you handle a 'loading' state? When the submit button is pressed, I would like to show a spinner and disable all input fields
@lucachrist514610 ай бұрын
Hey great Video, how can I reset the Flow so I can validate the next inputs after
@gadeern15862 жыл бұрын
Thank you for the great content 🌻 But if we need to access the string resources what the use case will looks like?
@jeghamaymen Жыл бұрын
i am using a pure java and kotlin module for the domain layer so i'm doing the validation in the datasource class (data layer) and injecting that in the usecase class...
@chips0562 жыл бұрын
Hello there, great and pretty complete video! Thank you for your hard work Philipp I have a question: how do you End-to-End test it? I explicitly followed this video and the one with testing (linked to your Note app) and whenever I ask the test to click on the Submit button and check if I have a new Text() displayed (with the explicit error), my test fails since it doesn't seem to reload the layout. Did it already happen to somebody?
@yossimaskin1393Ай бұрын
1. How to handle navigation with this approach? Seems like the events passes directly from the composable to the viewmodel but what if i want to navigate in the navGraph itself in some events? 2. Isn't it too much to maintain 2 sides events (The channel for UI events)? Can't it be determined through the state value?
@kaletsugas Жыл бұрын
Hi Philipp, does this way of using state recomposes everything whenever you type a character on the textfields? Is there a more optimized way?
@gondaimgano2 жыл бұрын
I wish Jetpack Compose could have a Form widget just like Flutter which could remove the amount of boilerplate code to create such.
@taknikiniga2 жыл бұрын
unable to import mutableStateOf in my xml android project any alternative
@L4szcZ7 ай бұрын
Your example shows that you are using strings in usecase. I think what you missed is that we need to map useCase to presenter object. Beacuse in standard compay project you would like to have strings in string resources.
@liosha20072 жыл бұрын
Thanks a lot. Very interesting and useful video 👍
@hariharanrc61922 жыл бұрын
Bro can you teach about how to use socket io using mvvm clean architecture pattern as there was no videos about socket io. It may help ful for my career as I came to android development by seeing your videos and I am be an good android developer because of you bro. If you don't mind can you teach us about socket io?
@sh3r1p49 Жыл бұрын
Hi Phillip, How could you handle multiple fields for example 5 swipeable pages with 10 fields on each page?
@shreyashachoudhary480 Жыл бұрын
Amazing quality content!
@miltonpimentel37692 жыл бұрын
Hey, I'm from Brazil and I love your videos, but I always miss something. unit test A suggestion, whenever possible add unit tests
@PhilippLackner2 жыл бұрын
I have a whole playlist about testing
@kokolight22 жыл бұрын
I have a weird question. Is there any chance that when using a state hosted in the viewmodel or in a data class as we did in this tutorial, the UI is rendered slower? For example, when I am creating a Switch, if I create the state in the same file of the Switch composable, the switch toggles fast. But whenever I host the state in the viewmodel as you described here, looks like it has a minor delay when I click the Switch. Do you know anything that can affect that? By the way, awesome tutorial!
@pereyrarg11 Жыл бұрын
very helpful, Thank you!
@smiley-zu5hn Жыл бұрын
Hi I hope you can Answer my question. I am following your steps but at the last part I get lost because I have an layout xml and I dont know how to connect it and use the validations. I hope you can help me thank you. New subscriber
@moldovanpeter51232 жыл бұрын
Hi, can you tell me an exact case when should we use SharedFlow (I watched some previous videos and you use them only for 1 observer(UI)), you mentioned it must have multiple observers. I just want to have a more accurate overview because there is another video where you compare LiveData vs Flows but also falls into the 1 observer category. Thanks.
@vijayjangid89674 ай бұрын
Thanks Philipp
@rohithkumar87552 жыл бұрын
Hii phil, thanks for the tutorial iam facing the issue like after succesful validation it is showing toast message pls provide me the solution.thanks
@yesayasoftware2 жыл бұрын
Philipp this is a very nice tutorial that... Thanks
@PhilippLackner2 жыл бұрын
Glad you liked it!
@mustafaammar5512 жыл бұрын
Very cool video Thank you Bro You are the best 👍👍👍🔥🔥🔥
@dkk00112 жыл бұрын
Hi @Phil, Any way can we improve recomposition, Here for any one of field value change all other fields also effecting .
@azemzejnilovic28932 жыл бұрын
Do you have this but without Jetpack?
@ubersticks2 жыл бұрын
Is it a good idea to expose mutable state from the ViewModel? Perhaps use "private set"?
@bitwisedevs4692 жыл бұрын
I think it is supposed to be assertEquals(false, result.successful)? Since the second param is `actual`
@NghiaNguyen-vn9wl Жыл бұрын
Could you guide full test course for android?
@MohammedElotol2 жыл бұрын
Great work! it is better to call it EmailValidator instead of ValidateEmail
@PhilippLackner2 жыл бұрын
Nah, that's kind of the convention for a use case, since you can execute them. It therefore makes more sense to think of them like a function, not like a class
@MohammedElotol2 жыл бұрын
@@PhilippLackner good point of view
@leryan07 Жыл бұрын
You were right, I was doing it wrong lol
@aguiarroney2 жыл бұрын
Why did you choose channel instead of LiveData? Great video, by the way!
@pa1shetty2 жыл бұрын
It will be emitted when activity re-creates ( scree rotation, theme change) . Correct me if I'm wrong.
@joojitaold2 жыл бұрын
22:00 What should I do if I have a large number of textfields? Should I repeat the proccess for each one still?
@PhilippLackner2 жыл бұрын
If you strictly want to follow clean architecture, yes. However, you might be able to reuse some use cases, for example if the logic for validating first names and last names is the same, then you might just use one ValidateName use case
@joojitaold2 жыл бұрын
@@PhilippLackner wow thanks for responding so quickly
@harisiqbal39862 жыл бұрын
Hi Phillip, which theme you are using for android studio
@PhilippLackner2 жыл бұрын
Xcode dark
@yoyo26-342 жыл бұрын
Hi nice thks. Didn't understand your comment on "abstracting the test on valid Email to avoid using Patterns in the validation class". What do you mean by that ?
@PhilippLackner2 жыл бұрын
The Patterns class comes from the Android framework. In local unit tests as we did it here, you can't use Android dependencies, so you need to write some kind of abstraction (interface) for this pattern stuff. For example like this: interface PatternValidator { fun isValid(pattern: String): Boolean } class EmailValidator: PatternValidator { override fun isValid(pattern: String): Boolean { return Patterns.EMAIL_ADDRESS.matcher(pattern).matches() } } Then you can pass a PatternValidator to your use case and use it without having the Patterns import in the use case. That way it stays unit testable.
@yoyo26-342 жыл бұрын
@@PhilippLackner very clear thks
@jeghamaymen Жыл бұрын
@@PhilippLackner how can we avoid using string ressources in the usecase where this should only be in a pure kotlin module ?
@amineayachi3352 жыл бұрын
thanks
@jjhoninatan55sabadi2 жыл бұрын
on UseCase you could use "operator fun invoke()", than call on ViewModel like function: validateEmail(email)
@dev_jeongdaeri2 жыл бұрын
Super cool 😎
@MaxTurchin2 жыл бұрын
Hello! Why are you using JUnit4 over 5? Thanks for your videos!
@PhilippLackner2 жыл бұрын
Doesn't give you many benefits, but requires some setup. In the end I want to run tests, that's it. And JUnit4 works perfectly for that. And AFAIK, JUnit5 doesn't work for instrumented tests
@ExploraByte2 жыл бұрын
Thanks for a great video and great content, can you make a video on how to implement firebase auth and firebase with clean architecture and jetpack compose
@jellybeast44082 жыл бұрын
where is the link from 11:52? also your insta link is dead 😸 luv ur videos btw!
@OrlanDroyd2 жыл бұрын
Great 👌
@RenatoSousaRS2 жыл бұрын
very nice!!!
@PhilippLackner2 жыл бұрын
Thanks!!
@tiltedbybox61182 жыл бұрын
Btw your instagram links are broken everywhere on youtube (video desc and on channel social media buttons)
@PhilippLackner2 жыл бұрын
Thanks man, because I changed the name. I'll fix it later. Appreciated
@quantumgaming72 жыл бұрын
Thanks but I’m never gonna use this 😂😂😂 it is actually way too overkill just to validate Authentication fields and if the forma is very big then the number of files gonna overkill just for a single form submission.
@PhilippLackner2 жыл бұрын
Overkill in a small app? Yes. Necessary to make big apps scale further? Absolutely.
@kajosan792 жыл бұрын
What a nasty manner of not putting a space between if and the parenthesis.
@aliffridzuan882 жыл бұрын
bloc architecture...
@kawsarhossain89312 жыл бұрын
⭐⭐⭐⭐⭐
@animehub8837 ай бұрын
when programming , show me the best practices, u not doing that , don't like that attitude sheesh
@LokendraBohara-s3u11 ай бұрын
channel shouldn't' be use here right ?? its bug prone.
@bboydarknesz2 жыл бұрын
I think this would be more readable way for MVVM when click button and Submit is success, then action. Instead handle the next action on top and hard to read. ex: Button(onClick = { viewModel.onEvent(Event.Submit) { gotoNextFragment() } }) but I don't know, I try it but not very clean in VM. WDYT? waiting for you video if you like this way. :D thank youu
@PhilippLackner2 жыл бұрын
But not every event you send to the VM returns success/failure, so that would only help for those that have