{"id":332090,"date":"2022-04-19T09:00:20","date_gmt":"2022-04-19T09:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332090"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332090","title":{"rendered":"<span>\u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c materialize \u0438 dematerialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0438 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Notification \u0432 RxJS?<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fec\/173\/3b6\/fec1733b619f743e0b7c4e1147dcb392.jpg\" width=\"4000\" height=\"2250\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fec\/173\/3b6\/fec1733b619f743e0b7c4e1147dcb392.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u0430\u043a <strong>materialize<\/strong> \u0438 <strong>dematerialize<\/strong> \u0432 RxJS? \u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Notification? \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438, \u0433\u0434\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0432\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041e\u0434\u043d\u0430\u0436\u0434\u044b, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0440\u0430\u0434\u0438, \u044f \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e RxJS \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0430 \u0440\u0430\u043d\u0435\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: materialize \u0438 dematerialize. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a: \u0430 \u0433\u0434\u0435 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435?<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435?<\/p>\n<h2>Materialize<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u044d\u043c\u0438\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 Observable: \u044d\u0442\u043e next, error \u0438 complete. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, <a href=\"https:\/\/rxjs.dev\/guide\/observable\">\u0437\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c.<br \/>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043f\u0440\u043e <a href=\"https:\/\/rxjs.dev\/guide\/observer\">observer<\/a>, \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u043e\u0432 (onNext, onError, onComplete), \u0442\u043e\u0436\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e materialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435: \u00ab<a href=\"https:\/\/rxjs.dev\/api\/operators\/materialize\">A function that returns an Observable that emits\u00a0Notification\u00a0objects that wrap the original emissions from the source Observable with metadata<\/a>\u00bb.<\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430: <br \/><a href=\"https:\/\/rxjs.dev\/api\/index\/function\/materialize\">materialize<\/a><strong>&lt;T>(): <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/interface\/OperatorFunction\">OperatorFunction<\/a><strong>&lt;T, <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\">Notification<\/a><strong>&lt;T> &amp; <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ObservableNotification\">ObservableNotification<\/a><strong>&lt;T>><\/strong>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, materialize <strong>\u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442<\/strong> \u043b\u044e\u0431\u043e\u0435 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0435 <strong>observable \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong> \u0432 \u043d\u0435\u043a\u0438\u0439 <strong>Notification<\/strong> \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u044d\u043c\u0438\u0442\u0438\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u00ab<strong>next<\/strong>\u00bb.<\/p>\n<p>\u0427\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\"><em>Notification<\/em><\/a>? \u042d\u0442\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 observable \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code>class Notification&lt;T> {   static createNext&lt;T>(value: T)   static createError(err?: any)   static createComplete(): Notification&lt;never> &amp; CompleteNotification   constructor(kind: \"N\" | \"E\" | \"C\", value?: T, error?: any)   get hasValue: boolean   get kind: 'N' | 'E' | 'C'   get value?: T   get error?: any   observe(observer: PartialObserver&lt;T>): void   do(nextHandler: (value: T) => void, errorHandler?: (err: any) => void, completeHandler?: () => void): void   accept(nextOrObserver: NextObserver&lt;T> | ErrorObserver&lt;T> | CompletionObserver&lt;T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void)   toObservable(): Observable&lt;T> }<\/code><\/pre>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0441 \u0437\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>kind. <\/em>\u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f observable: N \u2014 next, E \u2014 error, C \u2014 complete.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/47f\/a93\/d08\/47fa93d081eee15f79661bbba1cd9c6a.png\" width=\"1451\" height=\"544\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/47f\/a93\/d08\/47fa93d081eee15f79661bbba1cd9c6a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code>of(\u201cone\u201d) \/\/ \u043f\u043e\u0442\u043e\u043a \u044d\u043c\u0438\u0442\u0438\u0442 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f .pipe(materialize()) \/\/ \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432 Notification object .subscribe(x => console.log(x)); \/\/ \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 2 Notification  Output: {kind: \u201cN\u201d, value: \u201cone\u201d, error: undefined, hasValue: true} \/\/ Notification object {kind: \u201cC\u201d, value: undefined, error: undefined, hasValue: false} \/\/ Notification object<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043a \u044d\u043c\u0438\u0442\u0438\u0442 &#171;one&#187; -> materialize \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 Notification, \u0433\u0434\u0435 kind = &#171;N&#187; (next), \u0430 \u0432 value \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;one&#187;.<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f -> materialize \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 Notification, \u0433\u0434\u0435 kind = &#171;C&#187; (complete), \u0430 \u0432 value \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0442.\u043a. \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e materiailze \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, observable \u044d\u043c\u0438\u0442\u0438\u0442 \u0438\u0445 \u043a\u0430\u043a \u00abnext\u00bb, \u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044b\u0439 <em>complete <\/em>\u0432\u044b\u0431\u0440\u043e\u0441<em> <\/em>\u0432 next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 observable. <\/p>\n<p>\u0415\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>throwError(() => new Error(\u201cerror\u201d)) \/\/ \u044d\u043c\u0438\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 .pipe(materialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification .subscribe(x => console.log(x));  Output: {kind: \u201cE\u201d, value: undefined, error: Error, hasValue: false}<\/code><\/pre>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e materiailze \u0432\u0441\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432 Notification, \u0434\u0430\u0436\u0435 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<h2>Dematerialize<\/h2>\n<p>\u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0432\u044b\u0431\u0440\u043e\u0441\u0443 observable? \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <em>materialize<\/em> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>\u2014 dematerialize<\/em>, \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f.<\/p>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: \u00ab<a href=\"https:\/\/rxjs.dev\/api\/operators\/dematerialize\">Converts an Observable of Notification objects into the emissions that they represent<\/a>\u00bb.<\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<br \/><a href=\"https:\/\/rxjs.dev\/api\/index\/function\/dematerialize\">dematerialize<\/a><strong>&lt;N extends <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ObservableNotification\">ObservableNotification<\/a><strong>&lt;any>>(): <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/interface\/OperatorFunction\">OperatorFunction<\/a><strong>&lt;N, <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ValueFromNotification\">ValueFromNotification<\/a><strong>&lt;N>><\/strong>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/18b\/2cb\/f30\/18b2cbf3084742047a10fb0f0a7a5446.png\" width=\"1446\" height=\"525\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18b\/2cb\/f30\/18b2cbf3084742047a10fb0f0a7a5446.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code>\/\/ 1 \u043f\u0440\u0438\u043c\u0435\u0440 of(\u201cone\u201d) \/\/ \u044d\u043c\u0438\u0442\u0438\u0442\u0441\u044f \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a .pipe( materialize(), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification o\u0431\u044a\u0435\u043a\u0442   dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c Notification \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 .subscribe(x => console.log(x));  Output: \"one\" \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044d\u043c\u0438\u0442\u0438\u043b \u043f\u043e\u0442\u043e\u043a  \/\/ 2 \u043f\u0440\u0438\u043c\u0435\u0440 throwError(() => new Error(\u201cerror\u201d)) \/\/ \u044d\u043c\u0438\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 .pipe( materialize(), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification o\u0431\u044a\u0435\u043a\u0442   dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c Notification \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 .subscribe(x => console.log(x));  Output: \/\/ \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c,  ERROR Error: error \/\/ \u0432\u0438\u0434\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443<\/code><\/pre>\n<h2>\u0410 \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043e\u043d\u043e \u043c\u043d\u0435?<\/h2>\n<p>\u041c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b materialize \u0438 dematerialize. \u041d\u043e \u0433\u0434\u0435 \u0436\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f?  <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0433\u0434\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>\u2014<\/em> \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0431\u0430\u0433\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u044d\u043c\u0438\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438.  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:\u00a0<\/p>\n<pre><code>throwError(() => new Error(\u201cmessage\u201d)) .pipe(delay(3000)) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 .subscribe({ next: (x) => { console.log(`${x}`); }, error: (err) => { console.log(`${err}`); } complete: () => { console.log('complete'); } })<\/code><\/pre>\n<p>\u0422\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e, \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <a href=\"https:\/\/rxjs.dev\/api\/operators\/delay\"><em>delay<\/em><\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f next \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432.  <\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438. <\/p>\n<pre><code>throwError(() => new Error('message'))       .pipe(       materialize(), \/\/ \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c delay    y       delay(5000), \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443         dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0448\u0438\u0431\u043a\u0443       .subscribe({         next: (x) => { console.log(`${x}`); },         error: (err) => { console.log(`${err}`); },         complete: () => { console.log('complete'); },       });        Output: Error: message \/\/ \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b error \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0447\u0435\u0440\u0435\u0437 5 \u0441\u0435\u043a\u0443\u043d\u0434<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e materialize, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 delay.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 (\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dematerialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p><a href=\"https:\/\/stackblitz.com\/edit\/rxjs-materialize1\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/a><\/p>\n<h2>\u0413\u0434\u0435 \u0436\u0435 \u0435\u0449\u0435 \u043e\u043d\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f?<\/h2>\n<p>\u0421\u043a\u0430\u0436\u0435\u043c, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c 2 observable. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 observable \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 merge:<\/p>\n<pre><code>const result$ = merge(this.first$, this.second$)       .subscribe({         next: (x) => { console.log(`${x}`); },         complete: () => { console.log('complete'); },       });       this.first$.next(1);       this.second$.complete(); \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432       this.first$.next(2); \/\/ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d  Output: 1 2<\/code><\/pre>\n<p>\u041c\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 output &#171;complete&#187;. \u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e <a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge\"><u>merge<\/u><\/a> \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: \u00ab<em>The output Observable only completes once all input Observables have completed<\/em>\u00bb. \u0418 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b materialize \u0438 dematerialize:<\/p>\n<pre><code> const result$ = merge(       this.first$.pipe(materialize()), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification 1 \u043f\u043e\u0442\u043e\u043a        this.second$.pipe(materialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification 2 \u043f\u043e\u0442\u043e\u043a        )        .pipe(dematerialize()) \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e       .subscribe({         next: (x) => { console.log(`${x}`); },         complete: () => { console.log('complete'); },       });       this.first$.next(1); \/\/ Notification {kind: \"N\"}       this.second$.complete(); \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 - Notification {kind: \"C\"}       this.first$.next(2); \/\/ \u044d\u0442\u043e\u0442 next \u0443\u0436\u0435 \u043d\u0430 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442  Output:  1 \/\/ next \u043e\u0442 first$ complete \/\/ complete \u043e\u0442 second$ \u2014 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0442\u043e, \u0447\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u043b\u0438\u0441\u044c. \u0414\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e?<\/p>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 merge \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u0433\u043e observable. \u0410 materialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 observable \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0442\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u00abnext\u00bb \u0432\u044b\u0431\u0440\u043e\u0441.<\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c &#171;complete&#187; \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 this.second$ observable \u0432 pipe(&#8230;).<br \/>\u0418 \u0443\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dematerialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 observable \u2014 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p><a href=\"https:\/\/stackblitz.com\/edit\/rxjs-materialize2\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f materialize\/dematerialize, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0438 \u0433\u0434\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b.<\/p>\n<p>\u0423\u0432\u0435\u0440\u0435\u043d\u0430, \u0447\u0442\u043e \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 RxJS, \u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0410 \u0432\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u0445?<\/p>\n<hr\/>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/strong><\/p>\n<p><a href=\"https:\/\/rxjs.dev\/api\/operators\/materialize\"><u>https:\/\/rxjs.dev\/api\/operators\/materialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/rxjs.dev\/api\/operators\/dematerialize\"><u>https:\/\/rxjs.dev\/api\/operators\/dematerialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\"><u>https:\/\/rxjs.dev\/api\/index\/class\/Notification<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/class\/notification\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/index\/class\/notification<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/materialize\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/materialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/dematerialize\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/dematerialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge<\/u><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/skyeng\/blog\/661709\/\"> https:\/\/habr.com\/ru\/company\/skyeng\/blog\/661709\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u0430\u043a <strong>materialize<\/strong> \u0438 <strong>dematerialize<\/strong> \u0432 RxJS? \u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Notification? \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438, \u0433\u0434\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0432\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041e\u0434\u043d\u0430\u0436\u0434\u044b, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0440\u0430\u0434\u0438, \u044f \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e RxJS \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0430 \u0440\u0430\u043d\u0435\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: materialize \u0438 dematerialize. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a: \u0430 \u0433\u0434\u0435 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435?<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435?<\/p>\n<h2>Materialize<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u044d\u043c\u0438\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 Observable: \u044d\u0442\u043e next, error \u0438 complete. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, <a href=\"https:\/\/rxjs.dev\/guide\/observable\">\u0437\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c.<br \/>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043f\u0440\u043e <a href=\"https:\/\/rxjs.dev\/guide\/observer\">observer<\/a>, \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u043e\u0432 (onNext, onError, onComplete), \u0442\u043e\u0436\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e materialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435: \u00ab<a href=\"https:\/\/rxjs.dev\/api\/operators\/materialize\">A function that returns an Observable that emits\u00a0Notification\u00a0objects that wrap the original emissions from the source Observable with metadata<\/a>\u00bb.<\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430: <br \/><a href=\"https:\/\/rxjs.dev\/api\/index\/function\/materialize\">materialize<\/a><strong>&lt;T>(): <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/interface\/OperatorFunction\">OperatorFunction<\/a><strong>&lt;T, <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\">Notification<\/a><strong>&lt;T> &amp; <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ObservableNotification\">ObservableNotification<\/a><strong>&lt;T>><\/strong>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, materialize <strong>\u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442<\/strong> \u043b\u044e\u0431\u043e\u0435 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0435 <strong>observable \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong> \u0432 \u043d\u0435\u043a\u0438\u0439 <strong>Notification<\/strong> \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u044d\u043c\u0438\u0442\u0438\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u00ab<strong>next<\/strong>\u00bb.<\/p>\n<p>\u0427\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\"><em>Notification<\/em><\/a>? \u042d\u0442\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 observable \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code>class Notification&lt;T> {   static createNext&lt;T>(value: T)   static createError(err?: any)   static createComplete(): Notification&lt;never> &amp; CompleteNotification   constructor(kind: \"N\" | \"E\" | \"C\", value?: T, error?: any)   get hasValue: boolean   get kind: 'N' | 'E' | 'C'   get value?: T   get error?: any   observe(observer: PartialObserver&lt;T>): void   do(nextHandler: (value: T) => void, errorHandler?: (err: any) => void, completeHandler?: () => void): void   accept(nextOrObserver: NextObserver&lt;T> | ErrorObserver&lt;T> | CompletionObserver&lt;T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void)   toObservable(): Observable&lt;T> }<\/code><\/pre>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0441 \u0437\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>kind. <\/em>\u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f observable: N \u2014 next, E \u2014 error, C \u2014 complete.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code>of(\u201cone\u201d) \/\/ \u043f\u043e\u0442\u043e\u043a \u044d\u043c\u0438\u0442\u0438\u0442 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f .pipe(materialize()) \/\/ \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432 Notification object .subscribe(x => console.log(x)); \/\/ \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 2 Notification  Output: {kind: \u201cN\u201d, value: \u201cone\u201d, error: undefined, hasValue: true} \/\/ Notification object {kind: \u201cC\u201d, value: undefined, error: undefined, hasValue: false} \/\/ Notification object<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043a \u044d\u043c\u0438\u0442\u0438\u0442 &#171;one&#187; -> materialize \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 Notification, \u0433\u0434\u0435 kind = &#171;N&#187; (next), \u0430 \u0432 value \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;one&#187;.<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f -> materialize \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 Notification, \u0433\u0434\u0435 kind = &#171;C&#187; (complete), \u0430 \u0432 value \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0442.\u043a. \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e materiailze \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, observable \u044d\u043c\u0438\u0442\u0438\u0442 \u0438\u0445 \u043a\u0430\u043a \u00abnext\u00bb, \u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044b\u0439 <em>complete <\/em>\u0432\u044b\u0431\u0440\u043e\u0441<em> <\/em>\u0432 next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 observable. <\/p>\n<p>\u0415\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>throwError(() => new Error(\u201cerror\u201d)) \/\/ \u044d\u043c\u0438\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 .pipe(materialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification .subscribe(x => console.log(x));  Output: {kind: \u201cE\u201d, value: undefined, error: Error, hasValue: false}<\/code><\/pre>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e materiailze \u0432\u0441\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432 Notification, \u0434\u0430\u0436\u0435 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<h2>Dematerialize<\/h2>\n<p>\u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0432\u044b\u0431\u0440\u043e\u0441\u0443 observable? \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <em>materialize<\/em> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>\u2014 dematerialize<\/em>, \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f.<\/p>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: \u00ab<a href=\"https:\/\/rxjs.dev\/api\/operators\/dematerialize\">Converts an Observable of Notification objects into the emissions that they represent<\/a>\u00bb.<\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<br \/><a href=\"https:\/\/rxjs.dev\/api\/index\/function\/dematerialize\">dematerialize<\/a><strong>&lt;N extends <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ObservableNotification\">ObservableNotification<\/a><strong>&lt;any>>(): <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/interface\/OperatorFunction\">OperatorFunction<\/a><strong>&lt;N, <\/strong><a href=\"https:\/\/rxjs.dev\/api\/index\/type-alias\/ValueFromNotification\">ValueFromNotification<\/a><strong>&lt;N>><\/strong>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code>\/\/ 1 \u043f\u0440\u0438\u043c\u0435\u0440 of(\u201cone\u201d) \/\/ \u044d\u043c\u0438\u0442\u0438\u0442\u0441\u044f \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a .pipe( materialize(), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification o\u0431\u044a\u0435\u043a\u0442   dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c Notification \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 .subscribe(x => console.log(x));  Output: \"one\" \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044d\u043c\u0438\u0442\u0438\u043b \u043f\u043e\u0442\u043e\u043a  \/\/ 2 \u043f\u0440\u0438\u043c\u0435\u0440 throwError(() => new Error(\u201cerror\u201d)) \/\/ \u044d\u043c\u0438\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 .pipe( materialize(), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification o\u0431\u044a\u0435\u043a\u0442   dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c Notification \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 .subscribe(x => console.log(x));  Output: \/\/ \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f next \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c,  ERROR Error: error \/\/ \u0432\u0438\u0434\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443<\/code><\/pre>\n<h2>\u0410 \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043e\u043d\u043e \u043c\u043d\u0435?<\/h2>\n<p>\u041c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b materialize \u0438 dematerialize. \u041d\u043e \u0433\u0434\u0435 \u0436\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f?  <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0433\u0434\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>\u2014<\/em> \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0431\u0430\u0433\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u044d\u043c\u0438\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438.  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:\u00a0<\/p>\n<pre><code>throwError(() => new Error(\u201cmessage\u201d)) .pipe(delay(3000)) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 .subscribe({ next: (x) => { console.log(`${x}`); }, error: (err) => { console.log(`${err}`); } complete: () => { console.log('complete'); } })<\/code><\/pre>\n<p>\u0422\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e, \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <a href=\"https:\/\/rxjs.dev\/api\/operators\/delay\"><em>delay<\/em><\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f next \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432.  <\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438. <\/p>\n<pre><code>throwError(() => new Error('message'))       .pipe(       materialize(), \/\/ \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c delay    y       delay(5000), \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443         dematerialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0448\u0438\u0431\u043a\u0443       .subscribe({         next: (x) => { console.log(`${x}`); },         error: (err) => { console.log(`${err}`); },         complete: () => { console.log('complete'); },       });        Output: Error: message \/\/ \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b error \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0447\u0435\u0440\u0435\u0437 5 \u0441\u0435\u043a\u0443\u043d\u0434<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e materialize, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 delay.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 (\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dematerialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p><a href=\"https:\/\/stackblitz.com\/edit\/rxjs-materialize1\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/a><\/p>\n<h2>\u0413\u0434\u0435 \u0436\u0435 \u0435\u0449\u0435 \u043e\u043d\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f?<\/h2>\n<p>\u0421\u043a\u0430\u0436\u0435\u043c, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c 2 observable. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 observable \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 merge:<\/p>\n<pre><code>const result$ = merge(this.first$, this.second$)       .subscribe({         next: (x) => { console.log(`${x}`); },         complete: () => { console.log('complete'); },       });       this.first$.next(1);       this.second$.complete(); \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432       this.first$.next(2); \/\/ \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d  Output: 1 2<\/code><\/pre>\n<p>\u041c\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 output &#171;complete&#187;. \u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e <a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge\"><u>merge<\/u><\/a> \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: \u00ab<em>The output Observable only completes once all input Observables have completed<\/em>\u00bb. \u0418 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b materialize \u0438 dematerialize:<\/p>\n<pre><code> const result$ = merge(       this.first$.pipe(materialize()), \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification 1 \u043f\u043e\u0442\u043e\u043a        this.second$.pipe(materialize()) \/\/ \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 Notification 2 \u043f\u043e\u0442\u043e\u043a        )        .pipe(dematerialize()) \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e       .subscribe({         next: (x) => { console.log(`${x}`); },         complete: () => { console.log('complete'); },       });       this.first$.next(1); \/\/ Notification {kind: \"N\"}       this.second$.complete(); \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 - Notification {kind: \"C\"}       this.first$.next(2); \/\/ \u044d\u0442\u043e\u0442 next \u0443\u0436\u0435 \u043d\u0430 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442  Output:  1 \/\/ next \u043e\u0442 first$ complete \/\/ complete \u043e\u0442 second$ \u2014 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0442\u043e, \u0447\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u043b\u0438\u0441\u044c. \u0414\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e?<\/p>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 merge \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u0433\u043e observable. \u0410 materialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 observable \u0432 Notification \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0442\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u00abnext\u00bb \u0432\u044b\u0431\u0440\u043e\u0441.<\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c &#171;complete&#187; \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 this.second$ observable \u0432 pipe(&#8230;).<br \/>\u0418 \u0443\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dematerialize \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 observable \u2014 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p><a href=\"https:\/\/stackblitz.com\/edit\/rxjs-materialize2\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f materialize\/dematerialize, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0438 \u0433\u0434\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b.<\/p>\n<p>\u0423\u0432\u0435\u0440\u0435\u043d\u0430, \u0447\u0442\u043e \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 RxJS, \u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0410 \u0432\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u0445?<\/p>\n<hr\/>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/strong><\/p>\n<p><a href=\"https:\/\/rxjs.dev\/api\/operators\/materialize\"><u>https:\/\/rxjs.dev\/api\/operators\/materialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/rxjs.dev\/api\/operators\/dematerialize\"><u>https:\/\/rxjs.dev\/api\/operators\/dematerialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/rxjs.dev\/api\/index\/class\/Notification\"><u>https:\/\/rxjs.dev\/api\/index\/class\/Notification<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/class\/notification\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/index\/class\/notification<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/materialize\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/materialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/dematerialize\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/operators\/dematerialize<\/u><\/a><u><br \/><\/u><a href=\"https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge\"><u>https:\/\/docs.w3cub.com\/rxjs\/api\/index\/function\/merge<\/u><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/skyeng\/blog\/661709\/\"> https:\/\/habr.com\/ru\/company\/skyeng\/blog\/661709\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332090","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332090"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332090\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}