All Versions
27
Latest Version
Avg Release Cycle
52 days
Latest Release
357 days ago

Changelog History
Page 1

  • v2.1.8 Changes

    October 24, 2020

    ๐Ÿฑ The new version of render_async is out! ๐ŸŽ‰

    ๐Ÿฑ ๐Ÿ‘พ P.S. There is a render_async Discord server, please join and let's make render_async even better!

    The new version brings:

    • Reloading partials on demand
    • Start polling on page load when toggle is used
    • ๐Ÿ”ง Configure nonce globally
    • Assign start and stop events after the page loaded

    ๐Ÿฑ โ™ป๏ธ Refresh (reload) render_async partials

    This feature was requested in at least 3 issues opened on the repo recently. Finally, it is here!
    You can now provide a button for your users to easily refresh a partial that is render by render_async. Take a look at the example below:

    \<%= render\_async comments\_path, container\_id: 'refresh-me', replace\_container: false %\>\<button id="refresh-button"\>Refresh comments\</button\>\<script\>var button = document.getElementById('refresh-button')var container = document.getElementById('refresh-me');button.addEventListener('click', function() {var event = new Event('refresh');// Dispatch 'refresh' on the render\_async containercontainer.dispatchEvent(event)})\</script\>
    

    Now, every time a "Refresh comments" button is clicked, render_async will reload the comments partial. Hope you like the new feature.
    The issues closed with this feature: #121, #126, #129. More info in the docs here.

    ๐Ÿฑ ๐ŸŽ Start polling on page load when toggle is used

    We closed #118 with this feature. You can now specify start: true inside the toggle hash like this:

    \<a href='#' id='comments-button'\>Toggle comments loading\</a\>\<%= render\_async comments\_path,toggle: { selector: '#comments-button',event: :click,start: true },interval: 2000 %\>
    

    ๐Ÿ“„ This will make render_async to start polling on page load. Later, you can toggle polling with the "Toggle comments loading" button. There is more info in the docs here.

    ๐Ÿ”ง ๐Ÿ”ง Configure nonce globally

    You can specify nonces: true globally and never deal with it in specific render_async calls. Just add the following to your render_async configuration:

    RenderAsync.configure do |config| config.nonces = trueend
    

    ๐Ÿท After that, all javascript_tag elements will have nonce: true set. More info in the docs here.

    โฏ๏ธ Assign start and stop events after the page loaded

    ๐Ÿšš This is a bug fix mentioned in #128. We moved the event set up after the page loaded.
    If you had content_for inside the head tag, using async-start and async-stop will start working for you again.

    That's all folks, catch you in the next one!

    ๐Ÿฑ ๐Ÿ‘พ P.S. There is a render_async Discord server, please join and let's make render_async even better!

  • v2.1.7 Changes

    August 01, 2020

    ๐Ÿฑ ๐ŸŽ‰ New version of render_async is out! In the new version, there are a couple of new features:

    • Retry render_async after some time
    • Control polling by dispatching events
    • Customize content_for name

    ๐Ÿฑ ๐Ÿ‘พ P.S. There is a render_async Discord server, please join and let's make render_async even better!

    ๐Ÿฑ โ™ป๏ธ Retry render_async after some time

    If you want to retry requests but with some delay in between the calls, you can pass a retry_delay option together with retry_count like so:

    \<%= render\_async users\_path, retry\_count: 5, retry\_delay: 2000 %\>
    

    0๏ธโƒฃ This will make render_async wait for 2 seconds before retrying after each failure. In the end, if the request is still failing after the 5th time, it will dispatch a default error event.

    You can read more about this feature in the README here

    โฏ๏ธ Control polling by dispatching events

    You can now control polling with by dispatching these 2 events:

    • 'async-stop' - this will stop polling
    • 'async-start' - this will start polling.

    ๐Ÿฑ > ๐Ÿ’ก Please note that events need to be dispatched to a render_async container.

    An example of how you can do this looks like this:

    \<%= render\_async wave\_render\_async\_path, container\_id: 'controllable-interval', # set container\_id so we can get it later easily interval: 3000 %\>\<button id='stop-polling'\>Stop polling\</button\>\<button id='start-polling'\>Start polling\</button\>\<script\>var container = document.getElementById('controllable-interval')var stopPolling = document.getElementById('stop-polling')var startPolling = document.getElementById('start-polling')var triggerEventOnContainer = function(eventName) {var event = new Event(eventName);container.dispatchEvent(event)}stopPolling.addEventListener('click', function() {container.innerHTML = '\<p\>Polling stopped\</p\>'triggerEventOnContainer('async-stop')})startPolling.addEventListener('click', function() {triggerEventOnContainer('async-start')})\</script\>
    

    You can read more about it in the Controlled polling section of the README.

    Customize content_for name

    The content_for name may be customized by passing the content_for_name option to render_async.
    ๐Ÿ‘ This option is especially useful when doing nested async renders to better control the location of the injected JavaScript.

    For example:

    \<%= render\_async comment\_stats\_path, content\_for\_name: :render\_async\_comment\_stats %\>\<%= content\_for :render\_async\_comment\_stats %\>
    

    This explanation is also available in the README

    That's all folks, catch you in the next one!

    ๐Ÿฑ ๐Ÿ‘พ P.S. There is a render_async Discord server, please join and let's make render_async even better!

  • v2.1.6 Changes

    May 09, 2020

    ๐Ÿš€ Release 2.1.6 solves a couple of minor bugs:

    • Cannot stop polling after navigation changes (issue: #100, PR: #113)
    • Default headers don't get removed now (issue: #72, PR: #112) (this was an old one, glad we got it out of the way, finally)
    • Removed event.preventDefault() in toggle logic (issue: #109, PR: #110)
    • Fixed loading of nested partials with Turbolinks based on this comment #70 (comment), PR: #114

    ๐Ÿฑ Please test them out and post some findings if something is broken โค๏ธ

  • v2.1.5 Changes

    March 22, 2020

    ๐Ÿฑ ๐Ÿ”ฅ Firing events on success and fail by default

    0๏ธโƒฃ In this version, render_async will emit emits by default. If your request is finished successfully, a render_async_load event will fire. If it goes badly, the render_async_error will fire.

    You can then catch these events in your code with something like this:

    document.addEventListener('render\_async\_load', function(event) {console.log('Async partial loaded in this container:', event.container);});document.addEventListener('render\_async\_error', function(event) {console.log('Async partial could not load in this container:', event.container);});
    

    ๐Ÿฑ ๐Ÿ‘ Making DOM element available in events

    ๐Ÿ‘€ As you've seen in the previous example, you can now access event.container which will give you the associated DOM element. DOM element will be the one it just got replaced after the request has finished.

    ๐Ÿฑ ๐Ÿ”จ Fix of #90

    Toggle event listeners are not added after the page has loaded.

    Note

    If you're using jQuery to trigger an event like so

    $(document).ready(function(){$("#render-async-trigger").trigger('click');});
    

    ๐Ÿ”ง Make sure you're using render_async with jQuery configuration set to true!

    OR

    If you're using it with Vanilla JS (as is, as installed), make sure to register these events after the DOMContentLoaded is fired!

  • v2.1.4 Changes

    November 11, 2019

    ๐Ÿš€ This release solves #94 and allows you to unbind an event when using toggle functionality of the gem.

    You can unbind an event by passing once: true argument to render_async toggle option:

    \<%= render\_async comments\_path, toggle: { selector: '#detail-button', event: :click, once: true } do %\>\<a href='#' id='detail-button'\>Detail\</a\>\<% end %\>
    
  • v2.1.3 Changes

    October 24, 2019
    • #95: Use double quotes for displaying error message - @nikolalsvk.
    • #93: Fix: "Uncaught ReferenceError: _interval" #92 - @fffx.
  • v2.1.2 Changes

    August 30, 2019
  • v2.1.1 Changes

    August 16, 2019

    ๐Ÿ†• New release (2.1.1) let's you toggle when render_async gets loaded on the page.

    By passing in a toggle hash, you can trigger render_async by clicking or doing other things to HTML elements.
    You can trigger render_async by doing something like this:

    <a href='#' id='detail-button'>detail</a>
    <%= render_async comments_path, toggle: { selector: '#detail-button', event: :click } %>
    

    This will trigger render_async to load when the user clicks the "detail" link on the page. render_async won't load until that event is triggered.

    ๐Ÿ—„ DEPRECATION WARNING:

    If you've been using html_options as a second argument when calling render_async, you will have to change it to using a html_options hash like this:

    \<%= render\_async users\_path, html\_options: { nonce: 'lWaaV6eYicpt+oyOfcShYINsz0b70iR+Q1mohZqNaag=' } %\>
    
  • v2.1.0 Changes

    May 06, 2019

    ๐Ÿฑ Two new features come with 2.1.0 version! ๐ŸŒฎ

    Retry on failure

    render_async can now retry on request failure for number of times you specify

    \<%= render\_async users\_path, retry\_count: 5, error\_message: "Users fetch has failed" %\>
    

    Closed #46

    Polling feature

    ๐Ÿ“Š You can now poll your paths and URLs by passing interval option to render_async

    \<%= render\_async comments\_path, interval: 5000 %\>
    

    This will fetch comments_path every 5 seconds. Closed #67 with this feature.

    POSSIBLE BREAKING CHANGE if you use this feature

    Container element is NOT being replaced like in other cases. This means that you will have to deal with render_async container element. There are ways of doing this by passing in an HTML element name and HTML element class.

  • v2.0.2 Changes

    January 04, 2019

    Locked bundler dependency was making problems to some users #73

    ๐Ÿš€ This release removes bundler from gemspec file and solves the issue.