<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kristóf Tóth on Medium]]></title>
        <description><![CDATA[Stories by Kristóf Tóth on Medium]]></description>
        <link>https://medium.com/@kristoooth?source=rss-c4e551f7dce8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*R8sqasMxJWGqoDuHPD0IZQ.jpeg</url>
            <title>Stories by Kristóf Tóth on Medium</title>
            <link>https://medium.com/@kristoooth?source=rss-c4e551f7dce8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:18:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kristoooth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stopping event propagation in Angular]]></title>
            <link>https://medium.com/@kristoooth/stopping-event-propagation-in-angular-8d0d98b5f4b0?source=rss-c4e551f7dce8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d0d98b5f4b0</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[hostlistener]]></category>
            <category><![CDATA[directives]]></category>
            <dc:creator><![CDATA[Kristóf Tóth]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 08:47:46 GMT</pubDate>
            <atom:updated>2024-01-07T20:50:09.618Z</atom:updated>
            <content:encoded><![CDATA[<p>When you click onto a button in Angular, by default it notifies its parent about the event, which further notifies its parent, etc. What if you have some stucture in your HTML template where multiple structureal components handle clicks, like this:</p><pre>&lt;div (click)=&quot;someFunctionFirst()&quot;&gt;<br>  &lt;div (click)=&quot;someFunctionSecond()&quot;&gt;<br>    Further content... <br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>You guessed right, both functions fire as the click event is propagated. So, how could we achieve that only the inner function is fired?</p><p>The solution lies in directives:</p><pre>@Directive({<br>  selector: &quot;[click-stop-propagation]&quot;,<br>  standalone: true<br>})<br>export class ClickStopPropagationDirective<br>{<br>  @HostListener(&quot;click&quot;, [&quot;$event&quot;])<br>  public onClick(event: any): void<br>  {<br>    event.stopPropagation();<br>  }<br>}</pre><p>This directive stops the click event propagation to its parent, therefore only its event will be fired. HostListeners provide handler methods which are triggered when a specific event happens, you can read more about HostListeners <a href="https://angular.io/api/core/HostListener">here</a>, and about custom Directives <a href="https://medium.com/geekculture/custom-directives-in-angular-251080ef2b85">here</a>.</p><p>The custom directive can be applied to the HTML template like this:</p><pre>&lt;div (click)=&quot;someFunctionFirst()&quot;&gt;<br>  &lt;div click-stop-propagation (click)=&quot;someFunctionSecond()&quot;&gt;<br>    Further content... <br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>You just have to use the selector of the directive, and no more event propagation will happen!</p><p>I hope this helps in your Angular journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d0d98b5f4b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using websockets in a Spring Boot application]]></title>
            <link>https://medium.com/@kristoooth/handling-custom-websockets-in-a-spring-boot-application-28b3d10300dc?source=rss-c4e551f7dce8------2</link>
            <guid isPermaLink="false">https://medium.com/p/28b3d10300dc</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Kristóf Tóth]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 13:16:41 GMT</pubDate>
            <atom:updated>2023-06-23T10:12:51.705Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever been looking for a Spring Boot based websocket implementation that you could almost copy and paste into your project?</p><p>My guess is that if you were, then you came into the same implementation over and over which is described on the official website of spring: <a href="https://spring.io/guides/gs/messaging-stomp-websocket/">Getting Started | Using WebSocket to build an interactive web application (spring.io)</a></p><p>This is great for an interactive chat application where the messages you want to send across devices are string based, because this solution is based on STOMP protocol, which is a text-oriented message protocol.</p><p>In my project I was looking for a little bit different. My goal was to see applicants to an event in real-time. So after a lot of research I’ve found that the solution is very simple, yet it is not well documented across the Internet, so that is the goal of this article. :)</p><p>My code is written in Kotlin, which is similar to Java (but so much better :D).</p><pre>@Component<br>class MyWebSocketHandler : WebSocketHandler {<br><br>    override fun afterConnectionEstablished(session: WebSocketSession) {<br>        // your logic<br>    }<br><br>    override fun handleMessage(session: WebSocketSession, message: WebSocketMessage&lt;*&gt;) {<br>        // your logic<br>    }<br><br>    override fun handleTransportError(session: WebSocketSession, exception: Throwable) {<br>        // your logic<br>    }<br><br>    override fun afterConnectionClosed(session: WebSocketSession, closeStatus: CloseStatus) {<br>        // your logic<br>    }<br><br>    override fun supportsPartialMessages(): Boolean {<br>        // your logic<br>    }<br>}</pre><p>The component you are creating should implement the WebsocketHandler interface, therefore override it’s methods with your own logic. After adding those you are almost done. (It can be also beneficial to store sessions in a list but it’s up to you.)</p><pre>@Configuration<br>@EnableWebSocket<br>class WebSocketConfig(<br>    private val webSocketHandler: MyWebSocketHandler<br>) : WebSocketConfigurer {<br>    override fun registerWebSocketHandlers(registry: WebSocketHandlerRegistry) {<br>        registry.addHandler(webSocketHandler, &quot;/your-endpoint&quot;)<br>            .setAllowedOrigins(&quot;*&quot;)<br>    }<br>}</pre><p>If you register your websocket handler in your configurations you are done with implementing your custom websocket handler in your application. (With Kotlin and Spring Boot I can have MyWebSocketHandler automatically injected to my configurer.)</p><p>Be aware that you should protect your endpoints with authentication, don’t forget to protect these endpoints also.</p><p>Thank you for reading. Hope this helps in your project!</p><p>You can check out my project here: <a href="https://github.com/GuTory/letmein">GuTory/letmein: Event management software based on Spring Framework Backend and Angular frontend (github.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28b3d10300dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>