Agnes  Sauer

Agnes Sauer

1614932615

Avoid Memory Leaks and Unwanted Behavior when using RxJS mergeMap

I love rxjs… When I first started to use Angular, I tried to avoid it as most as possible (mostly because I really had difficulties to wrap my head around it) but now, I can’t imagine making any project without it.

However, as with every technology or framework, misusing it can have nasty consequences like memory leaks, application slowness or just undesired behaviors.

According to me, the most difficult concept in “rxjs” lies in higher order observables. For those who don’t know what that it is, it’s simply an observable that returns another one. Some examples of these ones would be “mergeMap”, “switchMap”, “exhaustMap”, etc…

I read some (really well written) articles about the differences between the aforementioned operators and I thought I understood the difference pretty well but today, I figured out the hard way that I didn’t. This article will simply highlight the trap I’ve fallen into for you not to do the same.

#angular #rxjs #programming #javascript

What is GEEK

Buddha Community

Avoid Memory Leaks and Unwanted Behavior when using RxJS mergeMap
Agnes  Sauer

Agnes Sauer

1614932615

Avoid Memory Leaks and Unwanted Behavior when using RxJS mergeMap

I love rxjs… When I first started to use Angular, I tried to avoid it as most as possible (mostly because I really had difficulties to wrap my head around it) but now, I can’t imagine making any project without it.

However, as with every technology or framework, misusing it can have nasty consequences like memory leaks, application slowness or just undesired behaviors.

According to me, the most difficult concept in “rxjs” lies in higher order observables. For those who don’t know what that it is, it’s simply an observable that returns another one. Some examples of these ones would be “mergeMap”, “switchMap”, “exhaustMap”, etc…

I read some (really well written) articles about the differences between the aforementioned operators and I thought I understood the difference pretty well but today, I figured out the hard way that I didn’t. This article will simply highlight the trap I’ve fallen into for you not to do the same.

#angular #rxjs #programming #javascript

Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

Read More

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

Appsinvo : What is the Internet of Behavior & the Future of IoB

Appsinvo has the best experience in developing IoT projects. Hence you can constant us for consultation with our professionals and get a huge reach in your business. Read More at : https://www.appsinvo.com/blog/what-is-the-internet-of-behavior-the-future-of-iob/

#benefits of internet of behavior #what is the internet of behavior used for? #what is the internet of behavior? #appsinvo

Kyle  M. Farish

Kyle M. Farish

1590112262

How to Avoid Memory Leaks in Node.js

To understand memory leaks, we first need to understand how memory is managed in Node.js. This means understanding how memory is managed by the JavaScript engine used by Node.js.

In this post, we’ll discuss How to Avoid Memory Leaks in Node.js

#node.js #javascript #react #memory leaks #programming

Shawn  Durgan

Shawn Durgan

1594877160

Two tips I got from Apple engineers to avoid Memory Leaks and increase efficiency

1. Avoiding retain cycles caused by capturing ‘self’ in a closure in a class

Swift uses Automatic Reference Counting (ARC) to manage its memory allocation and deallocation. This means that Swift automatically allocates memory to objects and then frees up that memory when the object is no longer in use (this is done by tracking the number of references of each object, zero references lead to deallocation).

While ARC manages most of the memory management, a strong reference cycle can lead to memory leaks from your app.

A common use case for such kind of a retain cycle is when self is captured inside a closure in a class.

“A strong reference cycle can also occur if you assign a closure to a property of a class instance, and the body of that closure captures the instance.” — Swift.org

In the Mentorship iOS app, we had these retain cycles while making the network calls and assigning properties in the sink operator.

import Foundation
	import Combine

	class Members: ObservableObject {
	    @Published var membersResponseData = [MembersModel.MembersResponseData]()
	    private var cancellable: AnyCancellable?

	    func fetchMembers() {
	        cancellable = NetworkManager.callAPI(urlString: URLStringConstants.members)
	            .receive(on: RunLoop.main)
	            .catch { _ in Just(self.membersResponseData) }
	            .sink { members in
	                // RETAIN CYCLE : strong capturing of self in a closure in a class
	                self.membersResponseData = members
	        }
	    }
	}

A closure, like a class, is a reference type. Hence, by capturing self inside a closure in a class we make a retain cycle; since the closure is captured by the class and the class is captured by the closure. As a result, in the above code, the class Members will never be deinitialized (memory leak!).

Solution:

The strong reference cycle can be easily solved by capturing weak self in the closure.

.sink { [weak self] members in
    self?.membersResponseData = members
}

#swiftui #programming #ios #memory-leak #swift-programming