Thursday 20 April 2023

Kotlin - Observer

 Rxjava - 

Observer - Based on data view willl render (react) karega.

trotling -> making stream for execution (Means clicks event fire krege ek particular duration m taki same event again & again call n ho) 

3 Major Component are there -

    1) Observable

    2) Observer

    3) Operator 


class MainActivity : AppCompatActivity() {

private var TAG:String = "MainActivity"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

var btn_throttleFirst : Button = findViewById(R.id.btn_throttleFirst)

btn_throttleFirst.clicks()
.throttleFirst(15000,TimeUnit.MILLISECONDS)
.subscribe {
Log.d(TAG,"throttleFirst duration : 15000 MLS")
}

simpleObserver()
}

private fun simpleObserver(){
var list = listOf<String>("member 1","member 2","member 3")
val observable = io.reactivex.rxjava3.core.Observable.fromIterable(list)

observable.subscribe(object : io.reactivex.rxjava3.core.Observer<String>{
override fun onSubscribe(d: Disposable) {
Log.d(TAG,"onSubscribe")
}

override fun onError(e: Throwable) {
Log.d(TAG,"onError")
}

override fun onComplete() {
Log.d(TAG,"onComplete")
}

override fun onNext(t: String) {
Log.d(TAG,"onNext")
}

})

}
}


output -

 throttleFirst duration : 15000 MLS


Wednesday 8 February 2023

Node-Js (REPL)

 1) Using For Debug JavaScript code & Experiment Code.

    R- READ 

    E- EVAL 

    P- PRINT 

    L- LOOP 


2) Make New File

    type nul > index.js <-|

3) Delete File

    del nul > Filename

4) Express Js - 

        It Will Provide Simple Rest Api's.

5) node install express --save

6) npm init


Friday 5 August 2022

SwiftUi - Login Page Example

 //

//  ContentView.swift

//  Chapter1

//

//  Created by Kamal Nishad.

//


import SwiftUI


struct ContentView: View {


    @State private var username: String = ""

    @State private var password:String = ""


    

    var body: some View {

        

        VStack{

            

            WelcomeText()

            UserImage()

            

            TextField("Enter Username",text: $username)

                .padding()

                .background(.regularMaterial)

                .cornerRadius(5.0)

                .padding(.bottom, 0)

        

            SecureField("Enter Password",text: $password)

                .padding()

                .background(.regularMaterial)

                .cornerRadius(5.0)

                .padding(.bottom,5)

            

            Text("Login")

                .font(.headline)

                .foregroundColor(.white)

                .padding()

                .frame(width: 150, height: 50)

                .background(Color.green)

                .cornerRadius(15.0)

 

        }

    }

}



struct WelcomeText:View{

    var body: some View{

       return Text("Welcome")

            .font(.largeTitle)

            .fontWeight(.semibold)

            .padding(.bottom,20)

    }

}


struct UserImage : View{

    var body: some View{

        return Image("profile")

            .resizable()

            .aspectRatio(UIImage(named:"profile")!.size,contentMode: .fill)

            .frame(width: 120, height: 120)

            .clipped()

            .cornerRadius(180)

            .padding(.bottom,20)

    }

}


struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}


Tuesday 17 May 2022

ReactiNative ListView

import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { Button, StyleSheet, Text, View,TextInput,ScrollView, } from 'react-native';

export default function App() {
  const [enteredGoalText, setEnteredGoalText] = useState('');
  const [courseGoals,setCourseGoals] = useState([]);

  function goalInputHandler(enterdText){
    setEnteredGoalText(enterdText);
  };

  function goalAddHandler(){
    setCourseGoals(currentCourseGoal => [
              ...currentCourseGoal,
              enteredGoalText,
            ]);
  };


  return (
    <View style={styles.appContainer}>
        <View style={styles.inputContainer}>
          <TextInput style={styles.textInput}
                     placeholder="Your course is here"
                     onChangeText={goalInputHandler} />
         
          <Button title='Sumbit' onPress={goalAddHandler}/>

        </View>
        <View style={styles.goalsContainer}>
          <ScrollView alwaysBounceVertical={false}>
                  {courseGoals.map((goal)=>
                      <View  key={goal} style={styles.goalItem}>
                        <Text style={styles.goleText}>{goal}</Text>
                      </View>
                    )}
          </ScrollView>
        </View>
    </View>
  );
}

const styles = StyleSheet.create({
    appContainer:{
      flex:1,
      paddingTop:20,
      paddingHorizontal:16,
    },
    inputContainer:{
      flex:1,
      flexDirection:'row',
      justifyContent:'space',
      alignItems:'center',
      padding:24,
      borderBottomWidth:1,
      borderBottomColor:'#cccccc',
      borderPaddingLef:24
    },
    textInput:{
      borderWidth:2,
      borderColor:'#cccccc',
      width:'70%',
      marginRight:8,
      padding:8,
    },
    goalsContainer:{
        flex:4
    },
    goalItem:{
      margin:8,
      padding:8,
      borderRadius:6,
      backgroundColor:'#5e0acc',
      color:'white',
    },
    goleText:{
        color:'white',
    },
    listTxt:{
      paddingLeft:24,
      paddingTop:10
    }
});

Thursday 10 February 2022

Nodejs - Prototype

 prototype = provide ability for adding new methods or class (Example- Inherit)


1) Home.js

var cal = require("./addition");
cal.addition();
console.log(cal.aval)

2) addition.js

module.exports={
    addition:function(){
        console.log("this is addition module");
    },
    aval:20
}


o/p ->

this is addition module

20


Nodejs- Templete String

 var name ="kamal"

var age = "26"


console.log("value of %s and %s",name,age)

//or

console.log("value one: "+name+"value two: "+age)

//now templete string example is...
console.log(`name ${name} age ${age}`)

Nodejs - Class Example

  Class Example

class users{                         ///creteing class

        constructor(name,age){              //declare constructor
            this.name =name;
            this.age=age;
        }
   
        getName(){
            this.email ="dev@gmail.com";
            return this.name;
        }

        getAge(){
            return this.age;
        }

        getEmail(){
            return this.email;
        }
}

///now crete object of class
var user = new users("kamal","26");
console.log(user.getName())
console.log(user.getAge())
console.log(user.getEmail()) ///agar getName() function define ne rhege pahle to undefine k error ayega



OUTPUT
kamal 26 dev@gmail.com




Kotlin - Observer

 Rxjava -  Observer - Based on data view willl render (react) karega. trotling -> making stream for execution (Means clicks event fire kr...