Comments (2)
There is no way to require it in a contract. Classes cannot be forced to have a companion object
, so it cannot be provided in the base library. This could only be done via code generation as a "bonus". But I wouldn't want to have it in the core generator engine. I could imagine a feature for others to hook into generation process to modify the output as they wish. But ATM this seems like an overkill for this simple feature request.
There is an extension on Class<Feature<T>>
, which allows you to use it like this YourFeature::class.java.defaultOption
. You can shorten it to KClass
with an extension wrapper.
public val <T : Feature<out T>> KClass<out T>.defaultOption: T
get() = java.defaultOption
from laboratory.
Sounds reasonable, thanks. I guess this idea could be revisited after statics.
The top-level function actually turned out just fine for us — most often type inference makes it simpler than a namespaced alternative.
class State(val authType: AuthType)
val initialState = State(authType = defaultOption())
from laboratory.
Related Issues (20)
- Make code generation module more resilient to ABI changes HOT 2
- Runtime crash with multi Application module project. HOT 2
- Generate option factory
- Use version catalogs
- Use typesafe project accessors
- Migrate to Gradle Kotlin Script HOT 1
- Migrate inspector to Compose UI HOT 1
- Enable GH code scanning alerts for Lint and Detekt
- Overrides of sources in `DefaultOptionFactory` are not respected
- Add laboratory dependencies as runtime dependencies HOT 1
- Handle deprecated features in option factory
- Support Gradle configuration cache HOT 2
- Can't generate feature flags with Kotlin 1.7.20 HOT 3
- Separate Kotlin version for library and samples
- Create a basic JVM sample and run it in the CI quality check
- Switch to Renovate Bot
- Multi-module: providing sources without feature factories HOT 3
- Expiration dates HOT 3
- Back icon instead of search icon in Inspector toolbar on Android 6.0
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 laboratory.