{"id":383,"date":"2018-10-15T01:37:03","date_gmt":"2018-10-15T01:37:03","guid":{"rendered":"http:\/\/www.bullcrane.com\/angular\/?p=383"},"modified":"2018-10-15T01:39:56","modified_gmt":"2018-10-15T01:39:56","slug":"transaction-integrity-improved","status":"publish","type":"post","link":"http:\/\/www.bullcrane.com\/angular\/2018\/10\/15\/transaction-integrity-improved\/","title":{"rendered":"Transaction integrity improved"},"content":{"rendered":"<p>\nIn my previous post, I proposed some enhancements to improve Shufflizer&#8217;s <a href=\"http:\/\/www.bullcrane.com\/angular\/2018\/10\/12\/transaction-integrity\/\">transaction integrity<\/a>.  These are done and in production now.  They are:\n<\/p>\n<ol>\n<li>The count of songs is confirmed on download and upload<\/li>\n<li>A temporary backup copy of the playlist is uploaded when doing same-playlist upload, and then deleted only if the same-playlist upload succeeds<\/li>\n<\/ol>\n<h4>I just wound up doing more callbacks<\/h4>\n<p>\nMost of the enhancements needed procedural (aka. synchronous) processing.  &#8220;Don&#8217;t do the following step, and don&#8217;t accept user input, until the current step finishes ok.&#8221;  I looked for something in ReactiveX&#8217;s JavaScript implementation to do this (RXJS), but did not find one.  Perhaps JavaScript&#8217;s await would have done it, but I realized that I could:\n<\/p>\n<ul>\n<li>make steps run in series using the usual approach &#8211; callbacks<\/li>\n<li>prevent user input with something I already had &#8211; the loading spinner<\/li>\n<\/ul>\n<p>\nSo I proceeded with additional layers of callbacks and moved my command that closes the loading spinner to the bottom layer.\n<\/p>\n<p>\nWhat I mean by a <em>callback<\/em> is a procedure that is called after the Observable, which is asynchronous, returns a value.  In this example deletePlaylist &#8220;calls back&#8221; to getPlaylists.  getPlaylists does not run until deletePlaylist returns a value:\n<\/p>\n<p><code><br \/>\nthis.spotSvc.deletePlaylist(b_plId,accessToken).subscribe(()=>this.getPlaylists(userId, userCountry, accessToken));<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post, I proposed some enhancements to improve Shufflizer&#8217;s transaction integrity. These are done and in production now. They are: The count of songs is confirmed on download and upload A temporary backup copy of the playlist is uploaded when doing same-playlist upload, and then deleted only if the same-playlist upload succeeds I &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.bullcrane.com\/angular\/2018\/10\/15\/transaction-integrity-improved\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Transaction integrity improved&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/383"}],"collection":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":16,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":399,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/383\/revisions\/399"}],"wp:attachment":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}