Комментарии:
Is it kind of DI for function?
Ответитьgood
ОтветитьHmm. After enabling the context receivers feature decompiler is not working. The decompiler is throwing this exception: java.lang.UnsupportedOperationException: Unsupported receiver value: ExampleScope: Ctx { class ContextAppliedClass }
ОтветитьIs there any comprehensive Kotlin Ktor tutorial that cover advanced topics and best practices? I can only time basic api and basic authentication
ОтветитьWhy making kotlin ugly ?
ОтветитьThe most intriguing part to me is how it could replace a great part of a DI framework to decouple our code from a third party DI framework!
Ответитьgreat explanation
ОтветитьIt is looks like analog of scala implicit/given feature
ОтветитьI cant believe this video lenght is 30+ mins. It feels like 5 mins when you get what he is saying. Thanks Sebbbbbbb!
ОтветитьGreat explained! Thank You! Context replaces the use cases of dependency injection libraries?
ОтветитьHmm, seems like it could help making dependency injection to functions when doing functional programming a bit cleaner
ОтветитьHow to solve the error?
`The feature "context receivers" is experimental and should be enabled explicitly`
That's freaking great! Given that you can have generic parameters passed to Context receivers it's practically Typeclasses! Can't wait for it's stabilisation and adoption by library authors!
Ответитьwith() should receive multiple parameters.
ОтветитьSorry android Developers we need to escape context too like the one we used with object as `object` and now context as `context`
ОтветитьYou are an excellent developer advocate for kotlin, keep up the great work.
ОтветитьIt sounds like a kind of Scala feature called "Implicit parameters". But in this case, with too boilerplate. 🤔
ОтветитьSome suggestion for the feature: There should be a "with function" with vararg parameters so in case of multiple context we don't have to embed that many times. It would look like with(logger, notification){ ... }. Also in the context function we should be capable to name the contexts like: context(Logger as logger, Notification as notification) or context(logger : Logger, notification : Notification). This would render these boxing interfaces unnecessary. Why isn't this an annotation by the way? Also if there is two interfaces in context(...) and one class implements both, an instance of that class should be enough.
ОтветитьThe EUR + USD example was quite enlightening, kudos!
ОтветитьI'm not quite sold on this yet. I'm really struggling to come up with a "real world" use-case for this feature where I wouldn't create a class and use constructor dependency injection instead. Interested to see how this evolves with the community response.
ОтветитьPlease 🙏 I have trying to get my app to come up when my phone boots completely but I haven't been able to achieve this, please do you know of any way or material that will help please I will be gland to check it up. Thanks
ОтветитьThis is one of the best explanations of a complex feature I've run into. Presentation is clear, gives markers to listener to wait for an explanation of a later thing, shows off clear examples in the left hand code sample. Fantastic!
Ответитьwow, this would unblocking a lot of ideas, and clean a lot of code as well 😆
let's go Kotlin 💪
Ah, IKEA.
ОтветитьGot this in mind for 3 years, glad it coming! :P
ОтветитьGreat Explanation. Thank you!
ОтветитьI like where this is going, we definitively need implicit parameters, but... I'm partial to Scala 3 way of doing things. Instead of context() adding a separate argument list + with() changing the scope of "this", Scala 3 added 2 keywords: "given" declares an implicit instance and the keyword "using" is used when implicit parameters are expected (both can be named or anonymous). Of course that Scala being Scala does way more than context receivers, but I l think that their way is a little bit cleaner. As it is, it feels like Kotlin is reusing "with" for something that it really shouldn't be used for.
ОтветитьThe presenter did a good job presenting the topic. However, this feature looks like an attempt to make Kotlin both less readable and less efficient. As a dev manager and tech lead, I can only imagine what atrocities my team will create with this feature. The dependency injection use case makes sense, and the plus infix operator is pretty cool. However, I wonder whether the convenience context receivers provides is worth the cost of the confusion that will result.
ОтветитьKotlin introduces Coroutines to solve "callback hell" and introduces with(), let(), apply() for "callback hell" !!
ОтветитьThanks for this! I see this as really useful when you need a dependency for ONE method in a class and don't want to inject a new object just for that one method, or don't want to store references in that class. This come with great power, and we all know what comes with great power... great electric bills
ОтветитьSpring framework to every house)
ОтветитьCan't wait for this feature to be added to the JS target! This is going to make writing Kotlin DSLs for javascript libraries so much nicer 🙏
ОтветитьDo no research at all ..lazy bums,.
ОтветитьI didn't know I need this
ОтветитьThis just seems like implicits with extra steps. Why not just implement implicits? What benefit do context receivers have that make them work the extra boilerplate?
Ответитьwhy dont just: with(firstContext, secondContext) { ... 🤔
ОтветитьSo "context" is gonna be a keyword and cannot be used as a field name anymore? God help us Android devs...
ОтветитьI would love to see this as a native DI for Kotlin. But needs to improve in some parts.
ОтветитьThanks for the great introduction to context receivers. Really looking forward to using them in production one day. Great stuff! And thanks to the Kotlin team, they’re doing an amazing job!
ОтветитьWell explained, thanks Seb. I think I have a couple of ideas on other ways to apply this. Experimentation time, may have to wait for compose to be upgraded to use Kotlin 1.6.20
ОтветитьMy feedback at this point:
1. this "context" keyword could be used as a keyword for a function parameter, I think it would be far nicer in the code and we could still use the names of those objects in the code of this function
2. context receivers would be optional, so you could still just pass this context object as a function parameter, this would not force us to use function that uses context receivers within "with" blocks when it is not necessary
3. I don't really like the idea of wrapping everything into interfaces (the problem in the part 2 of this video), why wouldn't we just use named context receivers, so like "context(name: Type)" and then we don't have resolution errors within the function code, I know that it would not let us to call the object as a receiver (so we would need to call "name.foo()" instead of just "foo()") but I would prefer it this way instead of forcing us to wrap everything in additional interfaces
Is that a laptop on top of the gray box on top of the bookcase? It's stressing me out 😬.
ОтветитьVery good video!
ОтветитьSwift.
ОтветитьI fundamentally disagree with the idea of adding even more anonymous variables.
ОтветитьLooks promising for DI and DSLs. I think usage outside of those two will most likely lead to horrible code though.
Ответитьkotlin is love S2
ОтветитьFirst of all: very nice and instructive video! I generally like the idea of context receivers, but I can already tell that people will sprinkle them around everywhere for no good reason. What bugs me a little is that we have yet another soft keyword (context) that could have been an annotation. Also, why is it that we don't have to write "::class" after the class name when declaring the context type? Did someone figure out after all that the class name alone might be enough to refer to the class, without needing the rather ugly ::class construct? ;)
Ответить