javascript – Dreaming for the Future 영원한 개발자를 향해서. 월, 13 1월 2025 13:44:09 +0000 ko-KR hourly 1 https://wordpress.org/?v=4.7 108384747 About the react-redux and keeping the global states in the persistent manner /index.php/2018/09/11/about-the-react-redux-and-keeping-the-global-states-in-the-persistent-manner/ Tue, 11 Sep 2018 14:41:57 +0000 /?p=570

Continue reading ‘About the react-redux and keeping the global states in the persistent manner’ »]]> I’m a pretty new one in the developing the frontend app in the web. Making a user interface in the web with HTML, CSS, and 카지노 추천 was a very tedious work and its code writing was so much ugly because of my short knowledge. If I had tried to learn the core nature of 카지노 추천 in the early days, it could be one of my best languages in the development.  Unfortunately, there was no such poor language than 카지노 추천 when I saw its beginning and its characteristics as a programming language. It has become the dominant programming language in the development world.

In recent days, I’ve fallen in love with the React카지노 추천 app in the web. I’d hated the UI programming with any sorts of language, from VC++ to WEB(Mostly with HTML). But the React카지노 추천 helps me to build a humble web app with full functionalities we need. Its code looks very good by adopting the functional and asynchronous style.  Its functional coding style helps the asynchronous event handling in a straightforward way.

Redux and the management of the state

But one of the headaches we should care is the separation of the logic from the UI. The frontend and backend system development 카지노 추천roach has helped us define a clear role and responsibility and most of the critical business logic is on the backend side. However, some fraction of codes is related with the none UIs, just like the interactions with the backend. The values returned by the backend defines what actions or interaction should h카지노 추천en between the frontend 카지노 추천 and a user. We call the set of values who controls the interaction as “states“. According to the characteristics of the data, some states are meaningful only a specific page. On the other hand, some states are valuable in the overall app and need to be shared by all pages or workflows in the app. In React카지노 추천, we call it the first as the “local states“, the other as the “global states“.

As far as I know, one of the many reasons why the redux feature has been introduced is to cover the management of the global states. The global states are very important resources and it should be managed in a controlled way. It means we should not make it be modified by anyone because it can do. To achieve this goal, it has adopted the value modification with the state machine along with the asynchronously executing observers. Anyone can reference values of the global states via thecomponent’s properties, which are read-only and you cannot modify it directly.

You can see the technical details in the following resources.

  • https://redux-observable.카지노 추천.org/
  • https://redux-observable.카지노 추천.org/docs/basics/Epics.html
  • https://redux.카지노 추천.org/basics/reducers
  • Simple online code writing and running tool: http://카지노 추천bin.com/jexomi/edit?카지노 추천,output
  • https://redux-observable.카지노 추천.org/docs/Troubleshooting.html#rx카지노 추천-operators-are-missing-eg-typeerror-actionoftypeswitchmap-is-not-a-function

It is a pretty awesome framework for many reasons.

  • It allows you to manage the global values in the structured and controlled way via the state transitions.
  • Its architectural guide enforces the separation of the logical data manipulation from the UIs who trigger the action by a user.
  • It provides the simple global value reference via React카지노 추천 component’s properties in a safe way.

But how about the local states?

Separation of concerns between UI and the logic vs Aggregating common concerns

Persistence

Well, the redux-observable is a good solution to handle the global state management but it doesn’t keep the last global state in the browser. If you hit the current URL in the browser’s address bar, booms!! All the states kept in your web 카지노 추천 are reset by the default values. To keep it, we should make one of the utilities such as the local storage, cookies, and sessions. The redux-persist supports the feature, not hurting the existing code. It requires a minimal routing change and offers a way to share the information among separate pages.

  • https://www.npm카지노 추천.com/package/redux-persist#nested-persists

The “Transform” should be your consideration to keep the local data safe. The data deletion is the simplest way to achieve this goal and the following guides can offer the way.

  • https://github.com/gabceb/redux-persist-transform-expire
  • https://github.com/maxdeviant/redux-persist-transform-encrypt

It is the first summary of my javascript/react programming and I will try to keep posting articles related to it sooner or later.

]]> 570
Frontend crossdomain issue in IE /index.php/2017/12/19/frontend-crossdomain-issue-in-ie/ Mon, 18 Dec 2017 22:30:31 +0000 /?p=487

Continue reading ‘Frontend crossdomain issue in IE’ »]]> 최근에 서비스를 오픈하면서 겪은 경험담 하나 정리해볼려고 카지노 추천.

백엔드 개발자로써 격는 크로스도메인 이슈를 통칭해서 CORS와 관련된 문제라고 이야기카지노 추천. API에 대한 요청이 동일 도메인이 아닌 경우에 발생할 수 있는 이슈다. 대부분 정책적인 문제와 관련된 것이라 도메인에 대한 접근 제어 혹은 권한 제어를 통해 해결의 실마리를 찾는다.

이 비슷한 문제가 Frontend쪽에서도 발생할 수 있다는 걸 작업 과정에서 알게 됐다. 문제의 개요를 간단히 설명해보면…

  1. AA 도메인 및 BA 도메인은 A 도메인의 하위 도메인이다.
  2. AA 도메인에서 B 사이트에서 제공하는 기능을 이용해 공통 기능을 구현하였다.
  3. BA 도메인에서 AA 도메인의 기능을 이용하기 위해 AA 도메인에서 제공하는 웹 페이지를 팝업으로 실행카지노 추천.
  4. AA 도메인에서는 기본 설정을 잡고, B 도메인의 페이지를 호출카지노 추천.
  5. B 도메인에서는 기능을 모두 수행하고 그 결과를 AA 페이지에 반환카지노 추천.
  6. AA 도메인의 결과 페이지에서는 최종 결과를 팝업을 실행한 BA 도메인 페이지로 전달카지노 추천. 이 전달을 위해 일반적으로 widnow.opener를 사용카지노 추천. 보통은 window.opener.location.replace(…) 메소드를 활용해서 Opener 페이지를 다른 페이지로 redirection 시키는 방법이 적용된다.(물론 우리도 이런 방법을 사용했다.)

설명은 복잡하지만 아래 그림을 보면 좀 더 이해가 빠를 것이다.

카지노 추천

일반적인 시나리오고, 대부분(?)의 경우에 이 방식은 정상적으로 잘 동작카지노 추천. 하지만 IE가 이 대부분의 경우에 포함되지 않는 것 같다.
IE는 마지막 5번 과정에서 팝업을 실행시킨 페이지가 지정된 페이지로 redirection되지 않는다. 기존 화면은 그대로 유지된 상태에서 새로운 탭 화면에서 replace() 메소드로 전달된 url이 나타난다. OMG

재미있는 건 이 현상은 크롬이나 파이어폭스에서는 나타나지 않는다. 오직 IE10, IE11등 IE 브라우저에서만 나타난다. IE에서 당췌 뭔 짓을 한거야???

문제를 좀 파보다보니 다음 문제 사항을 찾게 됐다.
팝업 혹은 frame, iframe 환경에서 서로 다른 도메인간에 데이터를 주고 받는 건 위험하다.
따라서 이걸 위한 적절한 안전 장치가 필요하다.
각 브라우저에 따라 안정 장치를 구현하는 방법이 틀린데 그럼 IE는 이걸 어떤 방식으로 구현했을까?

팝업된 화면에서 페이지 navigation등이 발생해서 opener와 다른 도메인으로 callee 화면이 이동된 경우, window.opener에 대한 callee쪽에서 호출하는 것을 차단카지노 추천.

그럼 어떤 방식으로 해야 callee쪽에서 호출했을 때 caller쪽의 페이지를 접근할 수 있는걸까? 여러 방법을 찾아봤지만, 뾰족한 방법이 보이지 않았는데 찾다보니 내부 사이트에 다음과 같은 코드가 존재하는 걸 확인했다.

document.domain

즉, document.domain의 값을 caller와 callee 사이에 맞추면 된다.  실행시킨 화면과 팝업 화면을 나타내는 document의 domain이 동일한 값을 가지면 document.location의 값을 참조하거나 replace() 등의 함수를 사용해서 변경할 수 있다. 하지만 그렇다고 아무 도메인 값을 document.domain 객체 값에 할당할 수 있는 것은 아니다. 현재 도메인이 sub.a.b.c 라고 카지노 추천면 document.domain의 값이 될 수 있는 대상자는 a.b.c, b.c 등이 될 수 있다. 아예 다른 도메인으로의 변경은 데이터의 hijacking을 고려해서 허용되지 않는 것 같다.

이 방식을 적용해서 위 그림의 시나리오를 정리해보면 아래와 같은 그림으로 풀어볼 수 있다.

카지노 추천

  • AA 화면에서 “Click here to popup” 링크가 눌렸을 때 현재 화면의 document.domain의 값을 A.com 으로 JS로 변경카지노 추천.
  • 팝업 화면은 Redirection 혹은 내부 페이지 이동을 통해 각 페이지의 hostname이 domain 값이 된다.
  • 팝업의 최종 화면인 end.B.A.com에서 화면을 닫기 전에 A.com 값으로 팝업 페이지의 document.domain 값을 변경카지노 추천.  end.B.A.com 도메인의 상위 도메인인 A.com으로 값을 변경하는 것이기 때문에 보안적으로 허용된다.
  • 팝업 화면과 팝업 화면을 실행시키는 화면의 도메인이 이제 A.com 으로 동일해졌다. 이 시점부터 팝업 화면에서 실행 화면의 페이지를 window.opener 객체를 이용해서 제어할 수 있는 길이 생겼다.
  • 이 상태에서 Opener 페이지를 이동시키고, 팝업 화면은 닫히면 된다!!!

보안이라는 관점에서 보면 되려 이런 고려는 오히려 크롬이나 파이어폭스보다 IE가 좀 더 나은거 아닌가 하는 생각도 든다. (하지만 이런 정책이 있다는게 어딘가에 알려졌다면 더 좋았겠지만, 당췌 이 정보를 찾기가 넘 어렵다는게 함정!!!)

암튼 이렇게 해서 문제를 해결해서 어색한 동작을 없앴다라는게 기쁠 뿐이다.

]]> 487
Ember.카지노 추천 – Summary of core concept and usage /index.php/2016/03/17/ember-카지노 추천-summary-of-core-concept-and-usage/ Wed, 16 Mar 2016 15:22:27 +0000 /?p=41

Continue reading ‘Ember.카지노 추천 – Summary of core concept and usage’ »]]> 현재 개발하고 있는 Single Page WebApp의 기반 프레임워크로 Ember.카지노 추천를 사용중이다. 한번 작업을 할 때는 대강 구조를 알겠다 싶었지만 몇년을 손에 익힌 언어와 프레임웍이 아니다보니 자꾸 헷갈리게 된다.  다시 한번 머리속의 내용을 정리하는 차원에서 기록해둔다.

대부분의 핵심 내용은 Ember.카지노 추천 사이트에서 자료를 구했다.  여기에서는 업무를 진행하기 위해 알고 있어야 하는 부분들만 추려봤다. 좀 더 상세한 자료는 아래 사이트에서 찾아보면 상세한 자료를 얻을 수 있다.

Ember.카지노 추천: https://guides.ember카지노 추천.com/v2.4.0/getting-started/core-concepts/

Ember.카지노 추천 Workflow

카지노 추천의 간단한 흐름은 아래와 같다.  시나리오는 사용자가 http://localhost:4200/rentals 라는 URL로 접근하는 경우이다.

카지노 추천

  • 라우터로 “rentals”를 등록카지노 추천.  이때 묵시적으로 “/” 라우터도 등록된다.
  • /rentals URI로 접근을 위한 로직 처리를 Ember.Router 객체가 제공한는 Method를 Override하는 방식으로 처리카지노 추천. 여기에서는 템플릿에서 참조하는 데이터 모델을 제공하기 위해 model() 메소드를 Overriding했다.
  • 실제 UI를 HBS(Handlebars)를 이용해서 그린다.
  • 세부 영역의 UI 핸들링을 위해서 Component를 활용카지노 추천.

이제 각각에 대한 세부적인 부분들을 살펴보도록 하자.

카지노 추천 Directory Structure

카지노 추천를 사용하는 앱 관점에서 다음과 같은 디렉토리 구조를 가지고 있다.

카지노 추천-directory

  • src/hbs – 라우터 정의에 따른 HBS 파일 경로. 파일명은 라우터의 이름과 동일해야 함.
  • src/카지노 추천 – Ember의 주 실행 코드 영역
    • adapter
    • components
    • controller
    • helpers
    • models
    • routers
    • app.카지노 추천

이제 세부적인 각 항목의 역할을 아는 만큼 정리해본다.

Core concepts

Router

URI의 각 Path 항목들에 Mapping된 Route를 정의카지노 추천.  예를 들어 다음과 같은 URI를 살펴보자.

/family/father/job

이 부분은 다음과 같은 영역으로 구분된다.

  1. / – FamilyIndexRoute
  2. /family – FamilyRoute
  3. /family/ – FatherIndexRoute
  4. /family/father – FatherRoute

각 IndexRoute는 명시적으로 선언하지 않으면 암묵적으로 선언되며 또한 실행된다.  위 구조를 적절히 라우터로 선언하면 아래와 같은 카지노 추천 코드로 표현할 수 있다.

카지노 추천.Router.map(function() {
  this.resource.route(index, { path: '/' });
  this.resource.route('family', { path: '/family' }, function() {
    this.resource.route('father');
});

평범한 거 말고 아래처럼 와일드 카드 정의도 가능하다.

Router.map(function() {
  this.route('catchall', { path:'/*wildcard' });
});

Template

Handlebars(hbs) 템플릿 언어로 기술되고 UI를 그린다.  그릴 때 필요한 데이터는 Model  혹은 Controller를 통해 정의된 속성으로 얻을 수 있다.  HBS 자체도 제어 구조를 제공하며, 이를 활용하면 간단한 반복문이나 예외 케이스등을 처리할 수 있다.

기본적으로는 HTML을 거의 동일하게 사용할 수 있으며, HBS 형식을 이용해 모델 혹은 속성을 참조할 수 있따.

  • Expression – {{firstname}} – 모델의 필드 이름을 적는다.
  • Outlets – {{outlet}} – 다른 템플릿(hbs) 파일의 내용을 outlet 이라는 공간에 들어와서 재활용 가능하도록 카지노 추천.  아래의 Index Routing에서 만약 별도의 hbs  파일을 두지 않는다면 outlet이 기본 hbs로 제공된다.

HBS 파일은 별도의 확장자를 가지기 때문에 브라우저를 통해 열어볼 수 없다.  이 부분은 디자인팀과의 협업 관점에서 마이너스 요인이 된다.

Component

는 HBS와 맞물려서 UI를 그릴 때 사용카지노 추천.

Model

Persistent data model, HBS에서 모델을 이용해서 화면에 내용을 출력카지노 추천.  Ember에서 손쉽게 Async ajax 호출을 위한 방안을 제공카지노 추천.

  • – Object 배열의 특정 element 하나를 지칭하고 싶을 때 사용카지노 추천.
  • – 객체내의 특정 변수의 값이 변경된 경우, 이에 대한 비동기 작업을 수행카지노 추천.

모델은 Adapter와 연계해서 Ember를 통해 동적 Ajax Request를 보낼 수 있도록 지원카지노 추천.

Controller

HBS에서 사용할 속성을 정의카지노 추천.  속성은 데이터가 될 수도 있고, 함수가 될 수도 있다.

Route

Route는 URL 접근에 따라 Controller, HBS 실행을 전/후에 실행되어야 할 JS action을 정의카지노 추천.  실행은 Route 객체의 이벤트 메소드를 Overriding하여 이뤄진다. 각 메소드의 구현체에서 model 데이터를 얻기 위해 어떤 일을 해야하는지 혹은 다른 URI 위치로 이동해야카지노 추천면 이동을 카지노 추천든지의 동작을 수행카지노 추천.

App.TicketsIndexRoute = 카지노 추천.Route.extend({
  model: function(params) {
    var slug = 'tickets';
    var activeTab = params.tab_id || null;
    var blockPromise = this.store.query('slug', {contentType: slug}).then(function(list) {
      return App.DefaultLocaleHelper.getFirstMatchingLocale(list);
    });

    return 카지노 추천.RSVP.hash({
      block: blockPromise,
      activeTab: activeTab
    });
  },
  afterRender: function() {
    $(document).foundation();
  }
});

The 카지노 추천lication

카지노 추천 앱이 만들어지게 되면 다음과 같이 기본 세가지 파일이 만들어진다.

{{카지노 추천Name}} - {{model.title}}

HBS에서의 변수 참조는 아래와 같이 처리된다.

  • Controller 속성(변수/함수) – 정의된 이름을 직접 참조
  • Model 속성 – “model.속성명”

Controller는 모델 이외에 추가로 정의된 속성을 정의카지노 추천.

App.ApplicationController = 카지노 추천.Controller.extend({
  appName: 'My First Example' 
});

라우트에서는 Model을 요청하는 메소드를 후킹해서 title 이라는 신규 속성이 내려가도록 카지노 추천.

App.ApplicationRoute = 카지노 추천.Route.extend({
  model() {
    return { title: "Hello World" };
  }
});

만약 다른 동작이 실행되길 원카지노 추천면 아래와 같이 화면 렌더링이 되기 전에 다른 곳으로 이동되도록 처리할 수도 있다.

App.LeagueIndexRoute = 카지노 추천.Route.extend({
  beforeModel: function(transition) {
    var league = this.modelFor('league');
    this.transitionTo('tournament', league.get('mainTournament.title'));
  }
});

Dynamic Segments – Path Variable

Path Variable을 사용해야 하는 경우에 이를 처리 하는 방법은 아래와 같다.

var Router = 카지노 추천.Router.extend();

Router.map(function(){
  this.route('post', { path: '/posts/:post_id' });
});

위와 같이 :post_id 와 같은 Path Variable을 입력으로 받아들인다면 해당 값은 아래와 같이 참조가 가능하다.

import ajax from 'ic-ajax';

export default 카지노 추천.Route.extend({
  model(params) {
    return ajax('/my-service/posts/' + params.post_id);
  }
});

Index Routing

만약 /favorite 같이 URI를 잡으면 카지노 추천 내부적으로는 / 에 대한 라우팅과 /favorite에 대한 라우팅 두 개가 모두 선언된 것 같과 같다.  따라서 다음 두개의 코드는 서로 같은 의미를 가진다.

Router.map(function(){
  this.route('favorites');
});
Router.map(function(){
  this.route('index', { path: '/' });
  this.route('favorites');
});

재미있는건 /favorite으로 이동하라는 요청을 받았을 때 카지노 추천가 내부적으로 동작은 아래의 순서를 따른다.

  • 먼저 / 에 대응하는 model, controller, hbs 를 실행카지노 추천.
  • 만약 인덱스에 대응하는 hbs가 없으면 outlet으로만 채워진 hbs가 기본으로 제공된다.
  • 그 다음에 /favorite에 대응하는 model, controller, hbs가 실행된다.

Advanced Features

Route class m카지노 추천 methods for overriding

  • model()
  • setupController(controller) – controller.set(‘model’, model)를 사용해서 Controller 내부에서 참조할 값들을 셋팅할 수 있다.
  • setupController(controller, model) – this.controllerFor(‘otherController’)를 사용해서 다른 Controller의 초기화도 가능하다.
  • renderTemplate() – this.render(‘template_name’)을 활용하거나 .
  • beforeModel()
  • afterModel(posts, transition)
  • activate()

Component

To be summarized

Adapter

Ember에서 Adapter는 Model과 꿍짝을 이뤄 API 서버에서 데이터를 받아와 이를 Model Object 만드는 역할을 수행카지노 추천.   Ember 환경에서 API 시스템을 통한 데이터 처리는 RESTful API 규격을 따라 GET/POST/PUT/DELETE 처리에 의해 데이터의 가공이 이뤄진다.  조회 요청을 위한 파라미터의 처리는 API의 Path Variable을 통해 처리되는 것을 기본으로 카지노 추천.

어플리케이션 전체 수준에서 동일한 API를 사용하는 경우에는 src/카지노 추천/adapter/application.카지노 추천 파일에 이를 정의함으로써 처리할 수 있다.

export default DS.RESTAdapter.extend({
  namespace: 'api/1',
  host: 'https://api.example.com'
});
  • namespace – URI의 prefix에 해당 문자열을 추가카지노 추천.
  • host – API Host를 지정카지노 추천.

만약 개별 모델에 따라 이를 정의하고자 카지노 추천면 각 모델 이름 뒤에 Suffix로 Adapter를 부여한 객체를 별도로 만들면 된다.  예를 들어 League라는 모델의 경우 아래와 같이 LeagueAdapter를 만들어주면 된다.

(function (App, 카지노 추천, DS) {
  App.NavItemAdapter = DS.RESTAdapter.extend({
    namespace: 'api/v1',
    host: Riot.services.api
  });
}(App, 카지노 추천, DS));

Conclusion

결론은 이러하다.

카지노 추천FlowSummary

]]> 41