Akita ๐Ÿถ์˜ ๋…ธ๋ ฅ ์ƒํƒœ ๊ด€๋ฆฌ

10262 ๋‹จ์–ด AngularRxJSAkita

๋ณธ ๊ธฐ์‚ฌ์— ๋Œ€ํ•˜์—ฌ


  • ์ด๋ฒคํŠธ ํ›„์— ์ƒ์„ธํ•œ ์„ค๋ช…์„ ์˜ฌ๋ ค ๊ธฐ์‚ฌํ™”ํ•ฉ๋‹ˆ๋‹ค


  • Who am I?



    jikoshokai.json
    {
      "name": "ไฝ่—คๆœ‰ๆ–—๏ผˆใ‚†ใ„ใจ๏ผ‰",
      "ไฝœใฃใฆใ‚‹ใ‚‚ใฎ": "BtoB SaaS",
      "ใ‚„ใฃใฆใ‚‹ใ“ใจ": ["ใƒใƒƒใ‚ฏใ‚จใƒณใƒ‰", "ใƒ•ใƒญใƒณใƒˆใ‚จใƒณใƒ‰", "ใ‚คใƒณใƒ•ใƒฉ"],
      "่จ€่ชž": ["Scala", "Typescript", "Python", "Ruby"],
      "ใ‚นใƒžใƒ–ใƒฉ": { 
        "ใ‚ญใƒฃใƒฉ": "ใƒใ‚น",
        "ไธ–็•Œๆˆฆ้—˜ๅŠ›": 2000000
      }
    }
    


    ์ด ๋ฐœํ‘œ์˜ ๋ชฉํ‘œ


  • Akita๋ผ๋Š” ์ƒํƒœ ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ์ธ์ง€ ํ™•๋Œ€
  • ์‹ ๊ทœ ์•ฑ ๊ฐœ๋ฐœ์‹œ ์„ ํƒ์—


  • Classi Angular Night



    ๋ชจ์ฟ ์ง€


  • Akita์™€์˜ ๋งŒ๋‚จ
  • Akita๋ž€
  • AKita ๊ทธ๋ฆผ
  • Store, Service, Query
  • Entity Store
  • ์‚ฌ์šฉํ•ด ๋ณด์•˜๋˜ ์ 
  • ์–ด๋ ค์šด ์ 


  • Akita์™€์˜ ๋งŒ๋‚จ


  • Redux ๋ณด์ผ๋Ÿฌ ํ…œํ”Œ๋ฆฟ์— ์ง€์ณค๋‹ค
  • ๊ฐ„๋‹จํ•œ ๊ฒƒ์„ ์›ํ•ฉ๋‹ˆ๋‹ค
  • ๊ทธ๋Ÿฌ๋‚˜ ์˜ฌ๋ ˆ์˜ฌ๋ ˆ RxJS๋Š” ์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค


  • ๊ทธ๋ž˜์„œ Akita์ž…๋‹ˆ๋‹ค.



    ์ฝ”๋“œ๋Š” ์—ฌ๊ธฐ

    Akita๋ž€?


  • ์ƒํƒœ ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ ํ•˜๋‚˜
  • ๋ณด์ผ๋Ÿฌ ํ…œํ”Œ๋ฆฌ๊ฐ€ ์ ๊ณ  ๋งค์šฐ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค
  • ๋กœ๊ณ ๊ฐ€ ๊ท€์—ฝ๋‹ค


  • Akita ๊ทธ๋ฆผ





    NgRx์™€์˜ ๋น„๊ต





    ์•„ํ‚คํƒ€์˜ 3๋กค


  • ๊ฐ’์„ ๋ณด๊ด€ ์œ ์ง€ํ•˜๋Š” Store
  • ๊ฐ’ ์–ป๊ธฐ Query
  • ๊ฐ’์„ ๊ฐฑ์‹ ํ•˜๋Š” Service (ํ†ต์‹ ๋„ ํ•œ๋‹ค)


  • ์Šคํ† ์–ด


    import { Injectable } from '@angular/core';
    import { Store, StoreConfig } from '@datorama/akita';
    import { Counter } from './counter';
    
    @Injectable({ providedIn: 'root' })
    @StoreConfig({ name: 'counter' })
    export class CounterStore extends Store<Counter> {
      constructor() {
        super({
          count: 0
        });
      }
    }
    

    Query


    @Injectable({ providedIn: 'root' })
    export class CounterQuery extends Query<Counter> {
      constructor(protected store: CounterStore) {
        super(store);
      }
    }
    

    ์„œ๋น„์Šค


    @Injectable({ providedIn: 'root' })
    export class CounterService {
      constructor(
        private counterStore: CounterStore
      ) {}
    
      set(countValue: number) {
        return this.counterStore.update({ count: countValue });
      }
    }
    

    Component


    export class CounterComponent implements OnInit {
      counter$: Observable<Counter>;
    
      constructor(
        private counterService: CounterService,
        private counterQuery: CounterQuery
      ) { }
    
      ngOnInit() {
        this.counter$ = this.counterQuery.select();
      }
    
      increment(current: number) {
        this.counterService.set(current + 1);
      }
    }
    

    ์˜ค์‚ฌ๋ผ์ด





    ๊ธฐ๋ณธ์€ ์ด๊ฒƒ๋ฟ ๐Ÿ•



    ์‘์šฉํŽธ



    Entity Store


  • ์ปฌ๋ ‰์…˜ ๊ตฌ์กฐ์— ํŠนํ™”๋œ Store
  • ์ฝœ๋ ‰์…˜ ์กฐ์ž‘์— ์ ์ ˆํ•œ ๋ฉ”์†Œ๋“œ๊ฐ€ ์ž๋ž๋‹ˆ๋‹ค


  • ์—ฌ๊ธฐ๋ถ€ํ„ฐ ์‹ค์ œ ์ฝ”๋“œ๋กœ ๐Ÿฉ



    ์‚ฌ์šฉํ•ด๋„ ์ข‹์•˜๋˜ ์ 


  • Rxjs ์ฃผ์œ„์˜ ๊ด€๋ฆฌ๋ฅผ ๋‘ฅ๊ธ€๊ฒŒ ๋˜์กŒ์Šต๋‹ˆ๋‹ค
  • ๋ณด์ผ๋Ÿฌ ํ…œํ”Œ๋ฆฌ๊ฐ€ ์ ๋‹ค


  • ์–ด๋ ค์šด ์ 


  • n ๊ฐœ์˜ Component ร— n ๊ฐœ์˜ Store
  • Angular์˜ Service์™€ Akita์˜ Service๊ฐ€ ์ž…๋Š”๋‹ค
  • ์ƒํƒœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š์•„๋„ ๋˜๋Š” ์„œ๋น„์Šค๋ฅผ ์–ด๋–ป๊ฒŒ ๊ด€๋ฆฌํ• ์ง€ ํ—ค๋งค๋‹ค


  • ์ฐธ๊ณ 


  • ์ด๋ฒˆ ์ฝ”๋“œ
  • ๊ณต์‹ ๋ฌธ์„œ


  • ๊ณ ๋งˆ์›Œ์š” ๐Ÿ•

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ