You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -242,62 +225,6 @@ Returns the prefix string used by the `LogService` object.
242
225
Sets a new prefix for the logger. This will change the *internal* prefix value used by the `LogService`. This function does not have the same
243
226
effect as `withPrefix()` which returns a new `LogService` object with a trail strings removed for the prefix.
244
227
245
-
### LogService.tap()
246
-
247
-
Creates an observable tapper that can listen for emitted values and output them to the browser's console. See [TapperMethods](#tappermethods) for more information.
248
-
249
228
### LogService.withPrefix()
250
229
251
230
Creates a new `LogService` object with the given prefix.
252
-
253
-
## TapperMethods
254
-
255
-
Create a `TapperMethods` object by calling `LogService.tap()` inside the `pipe()` of an observable. A tapper subscribes to an outer observable,
256
-
and creates a new inner observable that will only emit values to the browser's console. You can apply observable operators to this inner observable
257
-
via the [pipe()](#tappermethodspipe) and they will have no side effects on the outer observable.
258
-
259
-
For example, you can filter values:
260
-
261
-
```typescript
262
-
of(1,2,3,4,5).pipe(
263
-
logService.tap().pipe(filter(x=>x===3)).log()
264
-
).subscribe();
265
-
// prints "3" the console
266
-
```
267
-
268
-
The above applies a `filter()` operator to the tapper observable, but this filter has no side effects on the
269
-
original observable. Only output to the console is filter.
270
-
271
-
### TapperMethods.debug/error/info/log/warn()
272
-
273
-
The `TapperMethods` object has the same console methods as the `LogService`. The difference is that the tapper logging methods return an
274
-
observable operator. That means that the tapper logging methods have to be used inside an `observable.pipe()` method.
275
-
276
-
For example:
277
-
278
-
```typescript
279
-
of(1,2,3,4).pipe(
280
-
logService.tap().log()
281
-
).subscribe();
282
-
```
283
-
284
-
Because the tapper has to create an operator function the browser's console can not report the correct file name and line number. You
285
-
can use the `LogService` with a regular `tap()` operator if you need the file name, but you loose the ability to filter or map values
286
-
before they are printed to the console.
287
-
288
-
For example:
289
-
290
-
```typescript
291
-
of(1,2,3,4,5).pipe(
292
-
tap(val=>logService.log(val))
293
-
).subscribe()
294
-
```
295
-
296
-
### TapperMethods.pipe()
297
-
298
-
Adds observable operators to the inner observable that is tapping into the outer observables. Operators added to the
299
-
tapper will have no effect on the outer observable, but will be applied to the output for the console.
300
-
301
-
### TapperMethods.logger()
302
-
303
-
Returns the inner `LogService` used by the tapper for logging to the console.
0 commit comments