mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-08 19:44:16 +08:00
docs: merge some future to migrate docs
This commit is contained in:
@@ -58,50 +58,4 @@ All functions are expected to be completed in `2.0.0` version, so stay tuned.
|
||||
|
||||
- [New Xposed Module Config Plan](https://github.com/fankes/YukiHookAPI/issues/49)
|
||||
- [New Hook Entry Class](https://github.com/fankes/YukiHookAPI/issues/48)
|
||||
- [New Hook Code Style](https://github.com/fankes/YukiHookAPI/issues/33)
|
||||
|
||||
#### New Hook Code Style (Preview)
|
||||
|
||||
`YukiHookAPI` introduced the `New Hook Code Style` (New API) of `2.0.0` in the `1.2.0` version, it is now in the experimental stage.
|
||||
|
||||
You can before the `2.0.0` version is officially released, start migrating and experience the New API.
|
||||
|
||||
For example, we want to Hook the `test` method in the `com.example.Test` class.
|
||||
|
||||
> Legacy API
|
||||
|
||||
```kotlin
|
||||
findClass("com.example.Test").hook {
|
||||
injectMember {
|
||||
method {
|
||||
name = "test"
|
||||
}
|
||||
beforeHook {
|
||||
// Your code here.
|
||||
}
|
||||
afterHook {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> New API
|
||||
|
||||
```kotlin
|
||||
"com.example.Test".toClass()
|
||||
.method {
|
||||
name = "test"
|
||||
}.hook {
|
||||
before {
|
||||
// Your code here.
|
||||
}
|
||||
after {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The Hook object of the New API has been migrated from `Class` to `Member`, which will be more intuitive.
|
||||
|
||||
All legacy APIs have been marked `LegacyHookApi`, you can use `@OptIn(LegacyHookApi::class)` to eliminate the warning and continue to use the legacy API.
|
||||
- [New Hook Code Style](https://github.com/fankes/YukiHookAPI/issues/33)
|
Reference in New Issue
Block a user