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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bartblast" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bartblast/120/17647_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bartblast
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Hologram</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Let me clarify my current thinking on Hologram’s JS interop direction.</p>
<p><a class="mention" href="/u/eiji" rel="nofollow">@Eiji</a> - your examples are really helpful and show how high-level Hologram modules for abstracting JS Web APIs could work (like Hologram.DOM.query_selector, Hologram.DOM.add_event_listener, etc.). That’s a compelling proposition and we may very well go that way once simpler primitives are implemented and test themselves in battle.<br>
But for now, I’m focusing on the lower-level foundation - just enabling basic interfacing between the Elixir world and JS world. The goal is simple: allow calling JS code from Hologram and vice versa, something more primitive that those higher-level APIs could be built on top of - something that enables calling Web APIs or interfacing with existing JS code like in the example described by <a class="mention" href="/u/olivermt" rel="nofollow">@olivermt</a>.</p>
<p>I’ve been analyzing different approaches to JS interop across languages and frameworks and found three main categories that could apply to Hologram.</p>
<h2><a name="p-374282-h-1-messaga-passing-1" class="anchor" href="#p-374282-h-1-messaga-passing-1" aria-label="Heading link" rel="nofollow"></a>1. Messaga passing</h2>
<p>The first approach is message passing, like Elm’s ports (as mentioned by <a class="mention" href="/u/kingdomcoder" rel="nofollow">@kingdomcoder</a>) or Phoenix LiveView hooks.</p>
<p>In Elm, you define ports for sending data out and subscribing to data coming in:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">port sendData : String -&gt; Cmd msg
port receiveData : (String -&gt; msg) -&gt; Sub msg
</code></pre>
<p>Then in JavaScript, you connect to these ports:</p>
<pre data-code-wrap="javascript"><code class="lang-javascript">// Listen to data sent from Elm
app.ports.sendData.subscribe(function(data) {
    console.log("Received from Elm:", data);
});

// Send data to Elm
app.ports.receiveData.send("Hello from JS")
</code></pre>
<p>LiveView uses a similar pattern - it communicates with the JS world through hooks.</p>
<p><strong>Pros</strong>: Clear boundaries between language worlds, explicit control over data flow<br>
<strong>Cons</strong>: Communication overhead, forces async patterns even for simple operations</p>
<h2><a name="p-374282-h-2-foreign-function-interface-ffi-2" class="anchor" href="#p-374282-h-2-foreign-function-interface-ffi-2" aria-label="Heading link" rel="nofollow"></a>2.  Foreign Function Interface (FFI)</h2>
<p>The second is Foreign Function Interface (FFI), like Gleam uses. You declare external functions that map to JavaScript:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@external(javascript, "./my_js_file.mjs", "greet")
pub fn greet(name: String) -&gt; String
</code></pre>
<p>With corresponding JavaScript:</p>
<pre data-code-wrap="javascript"><code class="lang-javascript">export function greet(name) {
    return `Hello, ${name}!`;
}
</code></pre>
<p>This pattern is actually very common - most bindings with C/C++ libraries use this approach, and even Rust NAPI works similarly where you declare foreign functions that bridge between languages. For Hologram, this could look like declaring JS functions directly in Elixir modules.</p>
<p><strong>Pros</strong>: Direct function calls, minimal overhead<br>
<strong>Cons</strong>: Manual binding maintenance, potential runtime errors</p>
<h2><a name="p-374282-h-3-native-compilationinterop-3" class="anchor" href="#p-374282-h-3-native-compilationinterop-3" aria-label="Heading link" rel="nofollow"></a>3. Native compilation/interop</h2>
<p>The third approach is native compilation/interop, like Kotlin/JS. Since the code compiles to JavaScript, you can directly interface with JS:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">external fun alert(message: String)
external val console: Console

fun main() {
    alert("Hello from Kotlin!")
    console.log("Direct JS access")
}
</code></pre>
<p><strong>Pros</strong>: Natural integration, full ecosystem access<br>
<strong>Cons</strong>: Compilation complexity, language semantic mismatches</p>
<p>For Hologram, interestingly, the third approach doesn’t translate that well. While Hologram does compile to JavaScript, it uses its own client-side Elixir runtime rather than generating idiomatic JavaScript. This means we’re running Elixir semantics on top of JavaScript, and the different syntax and data types between JavaScript and Elixir (atoms, tuples, pattern matching, immutable data structures) don’t have direct JavaScript equivalents.</p>
<hr>
<p>What do you think? Which approach resonates most with your use cases?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374282" data-batch-url="/posts/batch_likers">
                        3
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-374282" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374282"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="374284" data-post-id="374284">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="olivermt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/olivermt/120/2354_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  olivermt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Make a poll? <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I vote 1, feels most idiomatic and a pattern we alrrady know</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374284" data-batch-url="/posts/batch_likers">
                        1
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-374284" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374284"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="374289" data-post-id="374289">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jam/120/36266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jam
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>At the moment, I’d vote 2. Seems simplest to me and feels like the most general / flexible which I think would be important. Though I would like to see some examples of 1 in the Hologram context.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374289" data-batch-url="/posts/batch_likers">
                        3
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-374289" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374289"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="374291" data-post-id="374291">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Eiji" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Eiji/120/36743_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Eiji
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="bartblast" data-post="13" data-topic="72518">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bartblast/48/17647_2.png" class="avatar"> bartblast:</div>
<blockquote>
<p>But for now, I’m focusing on the lower-level foundation - just enabling basic interfacing between the Elixir world and JS world. The goal is simple: allow calling JS code from Hologram and vice versa, something more primitive that those higher-level APIs could be built on top of - something that enables calling Web APIs or interfacing with existing JS code like in the example described by <a class="mention" href="/u/olivermt" rel="nofollow">@olivermt</a>.</p>
</blockquote>
</aside>
<p>Oh, that’s simple then. First we need a lot of structs (for window, document, element, event and all other data used in APIs). Then we need a helper functions (getters, setters for properties and apply) or sigil for a <code>JS</code> template, for example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def get_element_by_id(component_or_page, id) do
  component_or_page
  |&gt; Hologram.JS.get_document()
  |&gt; Hologram.JS.apply(:getElementById, [id])
end

def set_data(element, key, value) do
  element
  |&gt; Hologram.JS.get_property(:dataset)
  |&gt; Hologram.JS.set_property(key, value)
end

# or with templates:
def get_element_by_id(component_or_page, id) do
  assigns = %{document: Hologram.JS.get_document(component_or_page), id: id}

  ~HJS"""
  return {@document}.getElementById({@id});
  """
end

def set_data(element, key, value) do
  assigns = %{element: element, key: key, value: value}

  ~HJS"""
  return {@element}.dataset.{@key} = {@value};
  """
end
</code></pre>
<p>The first examples should be simpler than your 3rd option as we just need a few simple functions and some helpful structs that would be properly translated and received. The alternative with templates is similar to your 2nd <code>FFI</code> option. I don’t like the first option for message passing as it’s rather against <code>Elixir</code>’s 10x less code rule.</p>
<p>Personally I would prefer to not use templates for <code>JS</code>, but some bindings like in my first examples. They should be relatively simple to implement. I’m not sure how things work internally, but most probably you can do this just by enhancing your client-side <code>Elixir</code> runtime. You already translate data in templates, so you can do same with actions.</p>
<aside class="quote no-group" data-username="bartblast" data-post="13" data-topic="72518">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bartblast/48/17647_2.png" class="avatar"> bartblast:</div>
<blockquote>
<p>This means we’re running Elixir semantics on top of JavaScript, and the different syntax and data types between JavaScript and Elixir (atoms, tuples, pattern matching, immutable data structures) don’t have direct JavaScript equivalents.</p>
</blockquote>
</aside>
<p>I think that <code>JavaScript</code> equivalent for atoms are symbols, see:</p>
<blockquote>
<p><strong><code>Symbol</code></strong> is a built-in object whose constructor returns a <code>symbol</code> <a href="https://developer.mozilla.org/en-US/docs/Glossary/Primitive" rel="noopener nofollow ugc">primitive</a> — also called a <strong>Symbol value</strong> or just a <strong>Symbol</strong> — that’s guaranteed to be unique. Symbols are often used to add unique property keys to an object that won’t collide with keys any other code might add to the object, and which are hidden from any mechanisms other code will typically use to access the object.</p>
<p>Source: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol" class="inline-onebox" rel="noopener nofollow ugc">Symbol - JavaScript | MDN</a></p>
</blockquote>
<p>I believe that you can create <code>tuple</code>-like arrays in <code>JavaScript</code> by using <code>EcmaScript 2015</code> feature called <code>Object.seal</code>, see:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal">
  <header class="source">
      <img src="https://developer.mozilla.org/favicon.ico" class="site-icon" alt="" width="48" height="48">

      <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal" target="_blank" rel="noopener nofollow ugc">MDN Web Docs</a>
  </header>

  <article class="onebox-body">
    <img width="690" height="690" src="https://developer.mozilla.org/mdn-social-image.46ac2375.png" class="thumbnail onebox-avatar" alt="">

<h3><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal" target="_blank" rel="noopener nofollow ugc">Object.seal() - JavaScript | MDN</a></h3>

  <p>The Object.seal() static method seals an object. Sealing an object prevents extensions and makes existing properties non-configurable. A sealed object has a fixed set of properties: new properties cannot be added, existing properties cannot be...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<aside class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/21988909/is-it-possible-to-create-a-fixed-length-array-in-javascript">
  <header class="source">

      <a href="https://stackoverflow.com/questions/21988909/is-it-possible-to-create-a-fixed-length-array-in-javascript" target="_blank" rel="noopener nofollow ugc">stackoverflow.com</a>
  </header>

  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/1319904/daniel-howard" target="_blank" rel="noopener nofollow ugc">
    <img alt="Daniel Howard" src="https://www.gravatar.com/avatar/7d917910dd0525095eb5e7fbdba94445?s=256&amp;d=identicon&amp;r=PG" class="thumbnail onebox-avatar" width="256" height="256">
  </a>

<h4>
  <a href="https://stackoverflow.com/questions/21988909/is-it-possible-to-create-a-fixed-length-array-in-javascript" target="_blank" rel="noopener nofollow ugc">Is it possible to create a fixed length array in javascript?</a>
</h4>

<div class="tags">
  <strong>javascript, arrays</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/1319904/daniel-howard" target="_blank" rel="noopener nofollow ugc">
    Daniel Howard
  </a>
  on <a href="https://stackoverflow.com/questions/21988909/is-it-possible-to-create-a-fixed-length-array-in-javascript" target="_blank" rel="noopener nofollow ugc">01:15PM - 24 Feb 14 UTC</a>
</div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>I guess there are lots of ways for pattern-matching (if needed at all), see:<br>
<a href="https://github.com/suchipi/safety-match" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/suchipi/safety-match</a></p>
<p>I don’t think that immutable data structures needs to be translated.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374291" data-batch-url="/posts/batch_likers">
                        2
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-374291" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374291"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="374297" data-post-id="374297">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="frankdugan3" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/frankdugan3/120/39210_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  frankdugan3
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I like option 2. It’s naturally analogous to NIFs, so it feels like Elixir’s existing escape hatch into other languages. The async requirement of option 1 I think would be too complex for many use cases. Option 3 sounds like a nightmare to implement.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374297" data-batch-url="/posts/batch_likers">
                        3
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-374297" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374297"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="374299" data-post-id="374299">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="frankdugan3" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/frankdugan3/120/39210_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  frankdugan3
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>A follow-up thought: If these calls were automatically wrapped with try/catch, that could eliminate the problem of runtime errors, right? I’m sure that is some overhead, but I don’t know just how much. Perhaps try/catch would be the default wrapper, with an option to disable it for performance-critical calls. <img src="https://forum.elixirforum.com/images/emoji/apple/thinking.png?v=15" title=":thinking:" class="emoji" alt=":thinking:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374299" data-batch-url="/posts/batch_likers">
                        1
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-374299" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374299"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="374301" data-post-id="374301">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Eiji" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Eiji/120/36743_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Eiji
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Using <code>try/catch</code> for entre <code>JavaScript</code> API is rather an anti-pattern. Generally <code>Elixir</code> ecosystem prefers <strong>let it fail</strong> as fail and restart process is much simpler and therefore faster than catching all possible errors and passing all error data. I guess it would be better to let people spawn tiny processes.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374301" data-batch-url="/posts/batch_likers">
                        1
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-374301" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374301"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="374305" data-post-id="374305">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="olivermt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/olivermt/120/2354_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  olivermt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>But why would you want to «call» functions like that.</p>
<p>We are talking about interfacing with libs that you generally implement promises or callbacks for. The eventing system that hooks in lv already have to interface with this works very well.</p>
<p>With option 2 you need to hold all the client only state for a given third party flavour in hologram/elixir. That sounds like both a lot of work and a lot of friction. I just want to signal that hologram says to add three new markers or for the js side to send me an event saying that rhe viewport updated.</p>
<p>The foreign function way doesnt even solve that last thing.</p>
<p>Bidirectional message ish passing with events is both fully typeable and very simple to debug and test. And the hologram side needs to be a lot less degensively coded.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374305" data-batch-url="/posts/batch_likers">
                        3
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-374305" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374305"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="374313" data-post-id="374313">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="frankdugan3" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/frankdugan3/120/39210_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  frankdugan3
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t mean for the entire API, just at the boundary of the FFI interface to ensure an exception doesn’t crash the entire application.</p>
<p>Of course, if Hologram is already doing some sort of supervision tree emulation, that isn’t necessary and we can fall back on the let it fail ideology. I just assumed that wasn’t the case since we’re talking about calling into arbitrary JS here.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374313" data-batch-url="/posts/batch_likers">
                        1
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-374313" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374313"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
    <div class="postbit" id="374314" data-post-id="374314">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bartblast" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bartblast/120/17647_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bartblast
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Hologram</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="olivermt" data-post="14" data-topic="72518" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/olivermt/48/2354_2.png" class="avatar"> olivermt:</div>
<blockquote>
<p>Make a poll? <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I vote 1, feels most idiomatic and a pattern we alrrady know</p>
</blockquote>
</aside>
<p>I’d prefer to avoid basing architectural decisions on polls though <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"> Not that I don’t like polls, but I’m trying to provoke a deeper discussion here and am more interested in understanding the deeper trade-offs for Hologram’s specific context.</p>
<p>I’m honestly on the fence here and looking for someone to convince me why one of these approaches is genuinely better than the others. I don’t really care if something is familiar - what I care about is the best DX in general. Sure, familiarity might be part of DX, but there are many other factors like ease of use and ease of maintenance.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="374314" data-batch-url="/posts/batch_likers">
                        4
                      </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/time-for-hologram-javascript-interop-what-would-you-like-to-see/72518/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-374314" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="374314"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/72518/load_more?page=3">Load more posts (28 remaining)</a>
</div></template></turbo-stream>