Posts

Showing posts with the label python web development

Python’s Fake Increment and Decrement Operators

Image
Content Source: Python Web Development In Python, you can increase the value of a variable by 1 or reduce it by 1 using the augmented assignment operators. The code spam += 1 and spam -= 1 increments and decrements the numeric values in spam by 1, respectively. Other languages such as C++ and Java have the ++ and -- operators for incrementing and decrementing variables. (The name of C++ itself reflects this; the name is a tongue-in-cheek joke that indicates it’s an enhanced form of the C language.) Code in C++ and Java could have ++spam or spam++. Python wisely doesn’t include these operators; they are notoriously susceptible to subtle bugs. Reading more

Understanding TypeScript Interfaces

Image
Content Source: Angularjs Development Company An interface is a programming feature that helps to define the expected structure of an object allowing that to serve as a contract of sorts for the class where it is implemented. That helps explain the concept but how does this actually translate into working with real world code? Let’s say for example we have the following method: 1 2 3 4 public requestSpecificArea(lat : number, lng : number) : Observable {   return this.http.get(this._api + `locate-neighbourhood?q=${lat},${lng}`); } As you can gather from the code we’re using Angular’s HttpClient class to query a remote API which returns data as an observable that we can subsequently subscribe to. Continue reading

React Context API  –  A Replacement for Redux?

Image
Content Source: Angularjs Development Company With React is urging us to migrate to the new Context API. Context provides a way to pass data through the component tree without having to pass props down manually at every level. In React, data is often passed from a parent to its child component as a prop. This method has worked well in the past, but is not suitable for every kind of data. It will make things difficult later when moving components around. props even get passed down to child components which aren’t using the data. Is Context API a new thing? The truth is that Context has been a part of React for a really long time. Remember the <Provider> tag that we used earlier in the Redux app? It is actually a part of the older React Context API. React Context API is even used by libraries such as react-redux, MobX-react, react-router, and glamorous. So why is React Context API making such a big noise now? React used to discourage developers...

Socket.io – easy way to handle WebSockets

Image
Content Source: Python Web Development The era of static websites has passed. Now users demand dynamic content and application like look and feel. Instead of constantly reloading the page and hitting F5, the page should adjust itself automatically. Many of this can be accomplished with simple asynchronous requests from javascript. But what if you want to update your app only when there is a new data available on the server? You could send a ton of requests in a loop but that’ll use a lot of bandwidth and with more users could potentially DDoS your server or make it very slow. Web technologies are constantly evolving so it’s not exceptional that we have a solution for this problem. It’s called WebSockets. Websockets allows us to establish a stateful connection between browser and server so we can exchange pieces of information in both directions. It’s more efficient than standard request and response cycle from HTTP. Unfortunately, WebSockets are handled differentl...