Skip to content

Commit

Permalink
docs: add roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Aug 19, 2024
1 parent 833bc1c commit a8d57e4
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
34 changes: 34 additions & 0 deletions docs/docs/en/roadmap/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Roadmap

## v1 Version (Current Version) \{#v1-version}

> The functionalities are basically complete. Future work will focus on iterations over existing hooks, bug fixes, and ecosystem expansion.
### Automatic Dependency Collection \{#automatic-dependency-collection}

Migrating more hooks to use the **Automatic Dependency Collection** scheme. This is transparent to users but can significantly reduce unnecessary renders. For details, see [Dependency Collection](/docs/features/dependencies-collection).

## v2 Version \{#v2-version}

Improvements and optimizations will be made to address the issues and shortcomings of the current v1 version, which will introduce breaking changes:

### Adjust `useSupported` \{#adjust-use-supported}

Adjust the API return to expose the `isSupported` attribute as an object, enabling the Automatic Dependency Collection scheme. At the same time, force the user to explicitly specify a fallback function for "when the browser does not support the feature," aiming to explicitly remind developers to handle potential compatibility problems and reduce the likelihood of misuse.

> All internal hooks that depend on `useSupported` will be adjusted to fit the new API return format.
```tsx
// === Before Changing (v1) ===
const isSupported = useSupported(() => 'IntersectionObserver' in window)
console.log(isSupported) // true

// === After Changing (v2) ===
const { isSupported } = useSupported(() => 'IntersectionObserver' in window, {
// onUnsupported must be explicitly specified
onUnsupported: () => {
console.log('IntersectionObserver is unsupported.')
}
})
console.log(isSupported) // true
```
29 changes: 28 additions & 1 deletion docs/docs/zh-cn/roadmap/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# 后期规划(Roadmap)

## v1 版本(当前版本) \{#v1-version}

> 功能已基本完善,后期主要针对现有 Hooks 进行功能迭代、问题修复和生态扩充。
## V1(当前版本)
### 自动依赖收集 \{#automatic-dependency-collection}

迁移更多 Hooks 以使用**自动依赖收集**方案。对用户使用无感,但能显著降低不必要的渲染,详情参考 [依赖收集](/docs/features/dependencies-collection)

## v2 版本 \{#v2-version}

针对当前 v1 版本的问题和不足进行改进优化,会引入破坏性变更:

### 调整 `useSupported` \{#adjustments-to-use-supported}

调整 API 返回,以对象的形式暴露 `isSupported` 属性,以启用自动依赖收集方案。同时,在 API 层面强制用户显式指定「当浏览器不支持该特性时的」回退处理函数,这一更改旨在显式提醒开发者处理可能存在的兼容性问题,以降低错误使用的可能性。

> 将会对所有内部依赖 `useSupported` 的 Hooks 进行调整,以适配新的 API 返回形式。
```tsx
// === 更改前 (v1) ===
const isSupported = useSupported(() => 'IntersectionObserver' in window)
console.log(isSupported) // true

// === 更改后 (v2) ===
const { isSupported } = useSupported(() => 'IntersectionObserver' in window, {
// onUnsupported 必须显式指定
onUnsupported: () => {
console.log('IntersectionObserver is unsupported.')
}
})
console.log(isSupported) // true
```
8 changes: 8 additions & 0 deletions docs/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export const navbar = {
text: 'Reference',
link: '/reference',
},
{
text: 'Roadmap',
link: '/roadmap',
},
{
text: `v${version}`,
items: [
Expand Down Expand Up @@ -174,6 +178,10 @@ export const navbar = {
text: 'Hooks 列表',
link: `/${langSlug.zhCN}/reference`,
},
{
text: '后期规划',
link: `/${langSlug.zhCN}/roadmap`,
},
{
text: `v${version}`,
items: [
Expand Down

0 comments on commit a8d57e4

Please sign in to comment.