Skip to content

Commit

Permalink
Merge pull request #62 from Haoyue-zhi/patch-2
Browse files Browse the repository at this point in the history
Update 02-method-matcher.md
  • Loading branch information
JOU-amjs authored Dec 28, 2024
2 parents 53e6a8b + 230f284 commit 5287697
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/tutorial/03-client/02-in-depth/02-method-matcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getTodoList = currentPage =>
});

// Match all Method instances with the name `todoList`
const matchedMethods = alova.snaptshots.match('todoList');
const matchedMethods = alova.snapshots.match('todoList');
```

## Match by regular expression
Expand All @@ -44,7 +44,7 @@ By passing in a regular expression for matching, all method instance names that

```javascript
// Match all Method instances whose name starts with `todo`
const matchedMethods = alova.snaptshots.match(/^todo/);
const matchedMethods = alova.snapshots.match(/^todo/);
```

## Filter matching results
Expand All @@ -56,7 +56,7 @@ Let's look at a few examples.
**Invalidate the cache of the last method instance of a specific name**

```javascript
const matchedMethods = alova.snaptshots.match({
const matchedMethods = alova.snapshots.match({
name: 'todoList',
filter: (method, index, methods) => index === methods.length - 1
});
Expand All @@ -67,7 +67,7 @@ const matchedMethods = alova.snaptshots.match({
You can also set the second function of the `match` function to `false` to return the first item of the matching result, and return `undefined` if no match is found.

```js
const matchedSingleMethod = alova.snaptshots.match(/^todo/, false);
const matchedSingleMethod = alova.snapshots.match(/^todo/, false);
```

## Limit instance snapshots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getTodoList = currentPage =>
});

// 匹配name为`todoList`的所有Method实例
const matchedMethods = alova.snaptshots.match('todoList');
const matchedMethods = alova.snapshots.match('todoList');
```

## 通过正则表达式匹配
Expand All @@ -44,7 +44,7 @@ const matchedMethods = alova.snaptshots.match('todoList');

```javascript
// 匹配name为以`todo`开头的所有Method实例
const matchedMethods = alova.snaptshots.match(/^todo/);
const matchedMethods = alova.snapshots.match(/^todo/);
```

## 过滤匹配结果
Expand All @@ -56,7 +56,7 @@ const matchedMethods = alova.snaptshots.match(/^todo/);
**让特定名称的最后一个 method 实例的缓存失效**

```javascript
const matchedMethods = alova.snaptshots.match({
const matchedMethods = alova.snapshots.match({
name: 'todoList',
filter: (method, index, methods) => index === methods.length - 1
});
Expand All @@ -67,7 +67,7 @@ const matchedMethods = alova.snaptshots.match({
你还可以将`match`函数的第二个函数设置为`false`返回匹配结果的第一项,未匹配到时返回`undefined`

```js
const matchedSingleMethod = alova.snaptshots.match(/^todo/, false);
const matchedSingleMethod = alova.snapshots.match(/^todo/, false);
```

## 限制实例快照
Expand Down

0 comments on commit 5287697

Please sign in to comment.