docs: merge some future to migrate docs

This commit is contained in:
2023-10-07 16:29:05 +08:00
parent 5939e1dcd3
commit 6d82c28081
5 changed files with 323 additions and 94 deletions

View File

@@ -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)