<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="83972" data-post-id="83972">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="whatyouhide" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/whatyouhide/120/28912_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  whatyouhide
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Elixir Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Seeing this now after <a href="https://github.com/whatyouhide/stream_data/pull/104" class="inline-onebox" rel="nofollow">Add StreamData.repeatedly to pass in a function as your generator by aforward · Pull Request #104 · whatyouhide/stream_data · GitHub</a> has been opened. Just wanted to mention here too that I also think that a generic way to convert streams to generators would be nice but there is a big limitation: generators are stateless while streams aren’t. Streams are enumerated in order and there is no way for generators to know at which index in the stream it’s at.</p>
<p><a class="mention" href="/u/ericmj" rel="nofollow">@ericmj</a> also your solution can be even simpler as <code>bind</code> + <code>constant</code> is just <code>map</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def repeatedly(fun) do
  StreamData.map(StreamData.constant(nil), fn _ -&gt; fun.() end)
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="83972" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-create-a-custom-streamdata-generator/11935/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-83972" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="83972"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>